Home  >  Article  >  Backend Development  >  ThinkPHP uses GET method to obtain Chinese parameter query without results solution_PHP tutorial

ThinkPHP uses GET method to obtain Chinese parameter query without results solution_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:26:13832browse

When using ThinkPHP to make tags, a problem occurred, that is, the parameters can be obtained, but the corresponding results cannot be found. Check the database and find that the data exists. What's the problem?

Call in the form of http://www.XXXX.com/tags/index/%E8%87%AA%E5%8A%A8%E9%AA%8C%E8%AF%81.html

The parameters are encoded by urlencode(). Use the urldecode() function to decode and query again, but there is still no result.
Then the conversion encoding iconv() function was tested, and the result was successful.

The default encoding of the browser is GB2312, and this project uses UTF-8 encoding.
Let’s take a look at the wrong code and the corrected code:

$kw= $_GET['_URL_']['2'];   //错误的代码,在iis上能获取的参数,但是查询不出结果的。
$kw= iconv("gb2312","utf-8",$_GET['_URL_']['2']); //经过编码转换的,能够查询出结果的。

In addition, this method is only applicable to iis environment.
Also note that $_GET itself has the urldecode transcoding function when receiving parameters, and there is no need to perform urldecode decoding!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824775.htmlTechArticleWhen using ThinkPHP to make tags, a problem occurred, that is, the parameters can be obtained, but cannot be found. corresponding results. Check the database and find that the data exists. What's the problem...
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