Home  >  Article  >  Backend Development  >  Regarding the solution to the problem that the page script assignment fails due to carriage returns in the string when passing parameters in the url address_PHP Tutorial

Regarding the solution to the problem that the page script assignment fails due to carriage returns in the string when passing parameters in the url address_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:02:14844browse

When accepting parameters through the url address, the value V of some parameters has a carriage return '%0A'. At this time, when the page script is displayed, paying this value V to the script variable may cause script errors. .

So, correspondingly: URL-encode some strings when passing values ​​at the beginning, and then URL-decode when assigning values ​​in the script, so as to avoid the above problems.

In PHP, the operation functions for URL encoding are: urlencode() and urldecode()

The corresponding URL encoding operation functions in js are: encodeURI() and decodeURI()

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327935.htmlTechArticleWhen accepting parameters through the url address, the value V of some parameters has a carriage return '%0A', which When the page script is displayed, paying this value V to the script variable may cause errors in the script...
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