Php parameter garbled solution

Source: Internet
Author: User
: This article mainly introduces how to solve php parameter garbled characters. if you are interested in the PHP Tutorial, refer to it. When the website project uses gb2312 as the project code, because different browsers may have different Chinese character codes, some may encode Chinese as the website code, and some may encode Chinese as UTF-8, garbled error occurs when parameters are received in the background. A better solution is to encode the Chinese characters in the parameters. if it is not gb2312, it will be converted.

$ TypeName = $ _ GET ['typename']; $ encode = mb_detect_encoding ($ typeName, 'cp936, UTF-8 '); // if it is CP936, it is gbk encoding, if it is a UTF-8, it is UTF-8 encoded if ($ encode = 'utf-8') {// then call the function to convert to UTF-8 encoding, make sure it is UTF-8 $ typeName = iconv ("UTF-8", "gb2312", $ typeName );}

For website coding problems and future expansion, we recommend using uft-8 coding.

The above describes how to solve php parameter garbled characters, including some content, and hope to be helpful to friends who are interested in PHP tutorials.

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.