-1

I have this URL parameter:

KKe%7bZoE_%24g)tjm%40

When I put it into a variable and echo it, the result is:

KKe{ZoE_$g)tjm@

How to avoid that?

Yasen Ivanov
  • 973
  • 2
  • 8
  • 22
  • 1
    How do you put that into a variable? – DerApe Oct 26 '15 at 08:16
  • take a look into [urlencode](http://php.net/manual/en/function.urlencode.php) and [urldecode](http://php.net/manual/en/function.urldecode.php) – Tanuel Mategi Oct 26 '15 at 08:19
  • 2
    Possible duplicate of [URL Decoding in PHP](http://stackoverflow.com/questions/1756862/url-decoding-in-php) – l'L'l Oct 26 '15 at 08:22
  • OK, but when I use urlencode() the result is still different: **"KKe%7BZoE_%24g%29tjm%40"** – Yasen Ivanov Oct 26 '15 at 08:30
  • Be clear about what exactly you're doing, what you expect to happen and for what purpose. Your question is extremely vague and you will not get a useful answer with vague back and forth like this. – deceze Oct 26 '15 at 08:43
  • What I want to have is php variable, containing the exact URL as a string without any changes. This is verification code, that's why I use it. I want to send it again to check if the code is valid. – Yasen Ivanov Oct 26 '15 at 08:55

3 Answers3

1

Data in $_GET is already URL-decoded. If you require the original string, get it from $_SERVER['QUERY_STRING']. Note that you will have to process the query string yourself though, including breaking down the individual components.

Alternatively, use rawurlencode($_GET[..]) to re-encode the value; which may or may not produce slightly differently encoded values than you originally got.

deceze
  • 510,633
  • 85
  • 743
  • 889
0

Test it with html_entity_decode - it helpt me a lot with my inputs.

0

If the string is not shown as it is, you have urlencode() or htmlentities() somewhere in your code. Check that, you shouldn't encode html entities before echoing if you want the string to be intact.

onerror
  • 606
  • 5
  • 20