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

What should I do if php Chinese is not displayed?

藏色散人
Release: 2023-03-05 16:08:02
Original
3168 people have browsed it

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 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");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template