1

Possible Duplicate:
php javascript url encoding

if I encode a url with javascript's encodeURI(), will I be able to use PHP's url_decode to decode it without any possibility of error?

similar question for the other direction (encode with url_encode() in PHP, decode with javascript)

Community
  • 1
  • 1
kamikaze_pilot
  • 14,304
  • 35
  • 111
  • 171

1 Answers1

1

If you're attempting to pass a URI as a parameter, you'll probably want to use Javascript's encodeURLComponent() method. If I remember right, PHP's urlencode/urldecode methods expect all non-alphanumeric characters to be encoded (which Javascript's encodeURI does not seem to do).

For more information:
http://www.w3schools.com/jsref/jsref_encodeURI.asp
http://www.w3schools.com/jsref/jsref_encodeURIComponent.asp
http://us2.php.net/urlencode
http://us2.php.net/manual/en/function.urldecode.php

jszpila
  • 676
  • 9
  • 24