Home > php教程 > php手册 > body text

PHP在Linux的Apache环境下乱码解决方法

WBOY
Release: 2016-06-06 19:44:13
Original
960 people have browsed it

在windows平台编写的php程序默认编码是gb2312 而linux和apche默认的编码都是UTF-8 所以windows平台编写的php程序传到linux后,浏览网页中文都是乱码。 如果手工将php的编码用notepad++把编码改为UTF-8有可以显示正常 但如果程序多了,每个都改,工作量也比较

在windows平台编写的php程序默认编码是gb2312

而linux和apche默认的编码都是UTF-8

所以windows平台编写的php程序传到linux后,浏览网页中文都是乱码。

如果手工将php的编码用notepad++把编码改为UTF-8有可以显示正常

但如果程序多了,每个都改,工作量也比较大。

还有一种方式就是修改Apache的默认编码

具体位置为:

vim /etc/httpd/conf/httpd.conf

将原来的UTF-8注释掉,换上 gb2312 

#AddDefaultCharset UTF-8

AddDefaultcharset gb2312

 最后重启apache服务就可以了。

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