Modify the PHP configuration file PHP. ini to solve the utf8 garbled characters in XMLHTTP.

Source: Internet
Author: User

PHP uses XMLHTTP by default using the Utf-8 character set, and we use the gb2312 character set, which requires us to transcode gb2312 to the Utf-8.
PHP provides an optional code module that can convert multiple character sets. The method for loading this code module is as follows:

Open the PHP configuration file PHP. ini and remove the semicolon before extension = php_mbstring.dll (php_mbstring.so in Linux. After Apache is restarted, this module can be used. If an error occurs, check whether the path of the extended directory is set correctly.
After loading this module, we can use the mb_convert_encoding function for transcoding:
<?
$ Utf8_string = mb_convert_encoding ($ gb_string, 'utf-8', 'gb2312 ');
?>

Output The transcoded characters to view the correctly displayed Chinese characters.

ECHO to see.

click" add to Favorites " change the PHP configuration file PHP. INI solves utf8 garbled characters in XMLHTTP "

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.