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