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 "