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!