How to solve Chinese garbled characters in php.ini

藏色散人
Release: 2023-03-11 12:48:02
Original
4284 people have browsed it

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.

How to solve Chinese garbled characters in php.ini

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 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.

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!

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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template