Solution to PHP garbled characters in Linux Apache Environment

Source: Internet
Author: User
The default encoding of php program written on windows platform is gb2312 and the default encoding of linux and apche are UTF-8, so the php program written on windows platform is uploaded to linux, browsing the Chinese web page is garbled. If the manual php encoding with notepad ++ code to UTF-8 can display normal but if the program is more, each change, the workload is also compared

The default encoding of php program written on windows platform is gb2312 and the default encoding of linux and apche are UTF-8, so the php program written on windows platform is uploaded to linux, browsing the Chinese web page is garbled. If the manual php encoding with notepad ++ code to UTF-8 can display normal but if the program is more, each change, the workload is also compared

The default encoding of php programs written on windows is gb2312.

The default encoding for linux and apche is UTF-8

Therefore, after a php program written on windows is uploaded to linux, Chinese characters on the webpage are garbled.

If the manual php encoding with notepad ++ code to UTF-8 can display normal

However, if there are too many programs, each of them will be changed, and the workload will be relatively large.

Another way is to modify the default Apache encoding.

Location:

Vim/etc/httpd/conf/httpd. conf

Comment out the original UTF-8 and change it to gb2312

# Adddefacharset UTF-8

Adddefacharcharset gb2312

Restart the apache service.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.