How to change the PHP configuration file php.ini to solve the garbled code: first open the PHP configuration file [php.ini]; then remove the semicolon before [;extension=php_mbstring.dll]; finally restart Apache. Can.
How to change the PHP configuration file php.ini to solve the garbled code:
php uses XmlHttp and uses Utf by default -8 character set, and we mostly use the GB2312 character set, which requires us to transcode from GB2312 to Utf-8.
PHP provides an optional special code module that can realize mutual conversion between multiple character sets. The method to load this special code module is as follows:
Open the PHP configuration file php.ini and add ;extension=php_mbstring.dll
(linux is php_mbstring.so) Remove the semicolon.
After restarting Apache, this module can be used.
If an error occurs, please check whether the path setting of the extension directory is correct.
After loading this module, we can use the mb_convert_encoding
function to transcode:
<? $utf8_string = mb_convert_encoding($gb_string, ’UTF-8’, ’GB2312’); ?>
Convert the transcoded characters After the output, you can see the correctly displayed Chinese
echo and you will see it.
Related learning recommendations: PHP programming from entry to proficiency
The above is the detailed content of How to change the PHP configuration file php.ini to solve garbled characters?. For more information, please follow other related articles on the PHP Chinese website!