PHP resolve search in the URL address bar input Chinese characters found garbled search results

Source: Internet
Author: User

The premise of this problem is that the site code in utf-8 format, PHP space when the page stays in the search page, in the browser's address bar input Chinese keyword search will appear garbled, find information on the Internet, is because the browser by default in the URL in the middle character encoded in the gb2312 format, The file encoding in my program is used in the utf-8 format, so this problem occurs, but this problem does not occur if the data submitted directly from the form is used. The workaround is as follows and requires PHP to turn on mb_string support.

if (!mb_check_encoding ($word, ' utf-8 ')) {

$word = Iconv (' gb2312 ', ' utf-8 ', $word);

}

It is so simple, recorded, convenient for later search.

PHP resolve search in the URL address bar input Chinese characters found garbled search results

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.