Php gzip编码的响应无法解码

Php gzip编码的响应无法解码,php,apache,encoding,gzip,Php,Apache,Encoding,Gzip,我在php中使用gzip编码: ob_start("ob_gzhandler"); echo json_encode($arr); ob_end_flush(); 它在我的OpenServer上本地工作,但上传到生产环境中,浏览器不会对其进行解码 我明白了 而不是json对象。哪里会有问题 产品标题: Server: nginx/1.2.6 Date: Tue, 08 Sep 2015 11:30:56 GMT Content-Type: text/html; charset=WINDOWS-

我在php中使用gzip编码:

ob_start("ob_gzhandler");
echo json_encode($arr);
ob_end_flush();
它在我的OpenServer上本地工作,但上传到生产环境中,浏览器不会对其进行解码

我明白了

而不是json对象。哪里会有问题

产品标题:

Server: nginx/1.2.6
Date: Tue, 08 Sep 2015 11:30:56 GMT
Content-Type: text/html; charset=WINDOWS-1251
Content-Length: 3661
Connection: keep-alive
X-Powered-By: PHP/5.2.17
Content-Encoding: gzip
Vary: Accept-Encoding
本地标题:

Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:4066
Content-Type:text/html
Date:Tue, 08 Sep 2015 11:30:57 GMT
Keep-Alive:timeout=10, max=100
Server:Apache/2.2.27 (Win32)
Vary:Accept-Encoding

我不知道你的具体问题是什么;但是,您可能需要考虑使用:

这里不需要输出缓冲


如果要将结果直接发送到浏览器,请不要忘记设置正确的标题。如果您的浏览器仍然显示垃圾,您应该使用Firebug或DevTools之类的工具检查是否确实设置了标题。

我将其用于ajax请求,据我所知,浏览器在看到标题内容编码时会自动解码:gzip。使用gzencode,它不会在本地服务器上对其进行解码,而内容编码:gzip是缺席的,我在最初的问题中添加了标题。看起来他们是对的?呃哦:2010年反击战:
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:4066
Content-Type:text/html
Date:Tue, 08 Sep 2015 11:30:57 GMT
Keep-Alive:timeout=10, max=100
Server:Apache/2.2.27 (Win32)
Vary:Accept-Encoding
echo gzencode(json_encode($arr));