我正在设置ISO-8859-1的默认字符集,所以我将下面的代码添加到httpd.conf中。
AddDefaultCharset ISO-8859-9
当我查询它时,我可以看到这个值
root@server [/]# curl -A "Mozilla/4.0" http://localhost -I HTTP/1.1 200 OK Date: Mon, 10 Sep 2012 22:28:48 GMT Server: Apache Last-Modified: Tue, 21 Aug 2012 21:17:25 GMT Accept-Ranges: bytes Content-Length: 111 Content-Type: text/html; charset=ISO-8859-1
但是,我无法获得虚拟主机的相同结果,并且没有任何其他字符集的附加定义。
root@server [/]# file temp.php temp.php: ISO-8859 text root@server [/]# cat temp.php Cesária Évora root@server [/]# curl -A "Mozilla/4.0" http://somedomain/temp.php -I HTTP/1.1 200 OK Date: Mon, 10 Sep 2012 22:28:31 GMT Server: Apache Content-Type: text/html; charset=utf-8
你有什么主意吗 ? 请让我知道,如果你有线索。
谢谢。
Content-Type for PHP中的charset属性由php.ini处理。
将default_charset = iso-8859-1添加到您的php.ini中,或者在您的temp.php使用ini_set( "default_charset", "iso-8859-1" ) 。 http://www.php.net/ini.core#ini.default-charset