Home >Backend Development >PHP Problem >How to solve linux php garbled problem

How to solve linux php garbled problem

藏色散人
藏色散人Original
2020-07-31 10:16:122454browse

Solution to the Linux php garbled problem: first find and open the "httpd.conf" file; then modify the code to "AddDefaultcharset gb2312"; and finally restart the apache service.

How to solve linux php garbled problem

Recommended: "PHP Video Tutorial"

Solution to PHP garbled code in the Apache environment of Linux

The default encoding of php programs written on the windows platform is gb2312

The default encodings of linux and apche are both UTF-8

So the php programs written on the windows platform After the program is transferred to Linux, the Chinese characters on the web pages are garbled.

If you manually encode PHP using notepad and change the encoding to UTF-8, the display will be normal.

But if there are too many programs, changing each one will require a lot of work.

Another way is to modify the default encoding of Apache

The specific location is:

vim /etc/httpd/conf/httpd.conf

Comment out the original UTF-8 and replace it with gb2312

#AddDefaultCharset UTF-8
AddDefaultcharset gb2312

Finally, just restart the apache service.

The above is the detailed content of How to solve linux php garbled problem. 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