Home  >  Article  >  php教程  >  关于url地址传参数时字符串有回车造成页面脚本赋值失败的解决方法

关于url地址传参数时字符串有回车造成页面脚本赋值失败的解决方法

WBOY
WBOYOriginal
2016-06-13 11:44:141417browse

在通过url地址接受参数的时候,有些参数的值V带有回车' %0A ',这时候在页面脚本显示的时候,把这个值V付给脚本变量,可能会造成脚本的错误。

所以,相应的:一开始在传值的时候对一些字符串进行url编码,在脚本赋值的时候再进行url解码,这样就可以避免上面的问题。

在PHP中,对URL编码的操作函数是:urlencode()  和 urldecode()

对应在js中的URL编码操作函数是:encodeURI() 和 decodeURI()

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn