Home >Backend Development >PHP Problem >How to solve Chinese garbled characters in php.ini
php.ini method to solve Chinese garbled characters: first open the php.ini file; then find "default_charset = "iso-8859-1"" and change it to "default_charset = "UTF-8""; finally restart apache Serve.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How to solve Chinese garbled characters in php.ini?
php Chinese garbled processing method
I created a file in the local environment yesterday. The file encoding is UTF-8 format. When printing a simple statement, Chinese garbled characters appeared. It was frustrating. It took a long time to find the reason.
Garbled code problem
Yesterday I wrote a very simple PHP output Chinese page, but a garbled code problem occurred. The first reaction may be that there is a problem with the encoding format of the script file. , after looking at it, there is no problem. The original file is encoded as utf-8. What is the reason?
This is the first time I encountered this problem. Although you can add 3f948aea8d30d48a692b90ea22425202 to the output page, It can be temporarily solved, but this method treats the symptoms rather than the root cause and cannot solve the problem at all. Later, I checked online and found that it was a problem with the default character settings of the php.ini configuration.
You can also add a header to the header file in this way, but this method only treats the symptoms rather than the root cause. It is recommended to use the following method of modifying php.ini:
header("Content-type: text/html; charset=utf-8");
Solution
Open the php.ini file, find;default_charset = "iso-8859-1", change it to: default_charset = "UTF-8", remove the semicolon in front (remove the comment), and change the character set to UTF -8, restart the apache service, refresh the page, and the Chinese display will be normal.
This is recorded.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to solve Chinese garbled characters in php.ini. For more information, please follow other related articles on the PHP Chinese website!