php javascript url encoding

Andromeda picture Andromeda · Jul 9, 2009 · Viewed 27.8k times · Source

I have a html text. I had encoded it in php using urlencode function. I want to decode that text in the javascript. when i use unescape function in javascript it replaces all the special characters back but sapce is replaced by '+'. how can i do it correctly so that space is replaced as space itself???

Answer

Yasen picture Yasen · May 10, 2011

PHP rawUrlEncode() == JavaScript encodeURIComponent()

PHP rawUrlDecode() == JavaScript decodeURIComponent()