Reputation: 1358
I know about the PHP function encode() and decode(), they work well for me, but I want to pass the encoded string inside an url, but encode does return special chars like "=" "," "'" etc....
This does obviously break my script, what would be the best way to encode a string and get only numbers and characters?
Should I use a special hash?
Upvotes: 2
Views: 2870
Reputation: 6079
There is also a urlencode()
and urldecode()
method that respects special characters.
Furthermore, rawurlencode()
and rawurldecode()
are provided to encode according to RFC-3986. This will return a string in which all non-alphanumeric characters have been replaced with a percent (%) sign followed by two hexadecimal digits.
Upvotes: 4
Reputation: 6276
Try urlencode()
This should encode the encoded string in a way that you can safely pass it in an url.
Upvotes: 2