Solution of no result of Chinese parameter query obtained by ThinkPHP using GET

  • 2021-07-02 23:51:02
  • OfStack

When using ThinkPHP as tags tag, there is a problem, that is, the parameters can be obtained, but the corresponding results cannot be found. Look at the database and find that the data exists. What's the problem?

Calls like 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 (), decoded using the urldecode () function, and the query is still inconclusive.
The transcoding iconv () function was tested immediately, and the result was successful.

The browser default encoding is GB2312, and this project uses UTF-8 encoding.
Let's show you the wrong code and the revised code:


$kw= $_GET['_URL_']['2'];   // Error code, in iis Parameters that can be obtained on, but no results can be found in the query. 
$kw= iconv("gb2312","utf-8",$_GET['_URL_']['2']); // After coding conversion, the result can be queried. 

In addition, this method is only applicable to iis environment.
Also note that $_ GET has urldecode transcoding function when receiving parameters, so there is no need to decode urldecode!


Related articles: