php javascript url encoding

[亡魂溺海] 提交于 2019-11-30 00:02:09

Try using rawurlencode instead - urlencode does some things differently for "historical" reasons.

See http://us.php.net/manual/en/function.urlencode.php for more information.

PHP rawUrlEncode() == JavaScript encodeURIComponent()

PHP rawUrlDecode() == JavaScript decodeURIComponent()

Parenthesis are exceptions to all of what is said in this post.

geek mode on :

false

PHP rawUrlEncode() !== JavaScript encodeURIComponent()

but true

PHP rawUrlEncode() == JavaScript encodeURIComponent()

In other words, there are many special characters that aren't treated as safe in rawurlencode when they are in encodeURIComponent.

Try this:

return decodeURIComponent((str + '').replace(/\+/g, '%20'));

Source: http://phpjs.org/functions/urldecode:572

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!