不要在标题中设置字符集

时间:2016-06-01 16:28:05

标签: php apache header

如何避免PHP(或apache)在发送内容类型时自动将 charset = utf-8 添加到Content-type eader?

(原因是这会导致Internet Explorer出现问题)

orange public$ cat test.php 
<?php

header('Content-Type: text/xml');
orange public$ curl -v example.com.orange.me.local/test.php
#*   Trying 10.0.0.1...
* Connected to example.com.orange.me.local (10.0.0.1) port 80 (#0)
> GET /test.php HTTP/1.1
> Host: example.com.orange.imi.local
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Wed, 01 Jun 2016 16:24:49 GMT
< Server: Apache/2.4.18 (Ubuntu)
< Content-Length: 0
< Content-Type: text/xml;charset=UTF-8
< 
* Connection #0 to host example.com.orange.me.local left intact

1 个答案:

答案 0 :(得分:0)

我可以使用

删除字符集
ini_set('default_charset', '');

在我的脚本中

AddDefaultCharset off

在我的.htaccess