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

How to solve linux php garbled problem

藏色散人
Release: 2023-03-03 15:36:01
Original
2449 people have browsed it

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
Copy after login

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

#AddDefaultCharset UTF-8
AddDefaultcharset gb2312
Copy after login

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!

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