Home  >  Article  >  Backend Development  >  What should I do if php Chinese is not displayed?

What should I do if php Chinese is not displayed?

藏色散人
藏色散人Original
2020-09-02 09:17:243098browse

The solution to the problem that php Chinese is not displayed: first open the "php.ini" file; then modify the content to "default_charset = "UTF-8""; then restart the apache service; and finally refresh the page.

What should I do if php Chinese is not displayed?

Recommended: "PHP Video Tutorial"

php Chinese garbled processing method

Yesterday, I created a file in the local environment. The file encoding is in UTF-8 format. When printing a simple statement, Chinese garbled characters appeared. It took me 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. Question, the original file encoding is 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.

The above is the detailed content of What should I do if php Chinese is not displayed?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn