Thinkphp method of obtaining Chinese parameter query without result using GET method _php Example

Source: Internet
Author: User

When using thinkphp to do tags tags, there is a problem, is to get the parameters, but can not find the corresponding results. View the database to see that the data exists. What's the problem?

Call with the shape like http:/www.xxxx.com/tags/index/%e8%87%aa%e5%8a%a8%e9%aa%8c%e8%af%81.html

The parameter is encoded by UrlEncode (), and the UrlDecode () function is used to decode it, and then the query still has no result.
The Test Transformation Code iconv () function is followed by a successful result.

The default encoding of the browser is GB2312, and this item is UTF-8 encoded.
The following is the wrong code and the revised code for everyone to look at:

$kw = $_get[' _url_ '] [' 2 '];   Bad code, parameters that can be obtained on IIS, but the query does not produce results.
$kw = Iconv ("gb2312", "Utf-8", $_get[' _url_ '] [' 2 ']);//encoded, capable of querying the result.

In addition, this method applies only to the IIS environment .
Also note that$_get receive the parameters of the time itself has urldecode transcoding function, do not need to urldecode decoding operation!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.