2

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?

1
  • 1
    urlencode() Commented Apr 28, 2015 at 8:51

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Try urlencode()

This should encode the encoded string in a way that you can safely pass it in an url.

1 Comment

First encode the string the way you want it, then pass it through urlencode() to get an URL-suitable string. That string can then be passed through an URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.