可以用什么来代替 ob_start(“ob_gzhandler”);
可以使用什么来代替 ob_start("ob_gzhandler");
,这会导致 PHP 警告:无法修改标头信息 - 标头已在第 0 行未知中发送
?
我相信,之前提出过一些相关和/或有用的问题:
“未知”PHP 错误 - 这是什么意思?
PHP 警告:标头已以未知方式发送
What can be used instead of ob_start("ob_gzhandler");
which is causing PHP Warning: Cannot modify header information - headers already sent in Unknown on line 0
?
Some, as I believe, related and/or helpful questions asked before:
"Unknown" PHP error - what is that supposed to mean?
PHP warning: headers already sent in Unknown
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对我有用的(最后)是将
zlib.output_compression
放入 php.ini 并将其设置为 ON,成功替换ob_start("ob_gzhandler");
What worked for me (finally) was to put
zlib.output_compression
in php.ini and set it to ON, successfuly replacingob_start("ob_gzhandler");
只需将
ob_start("ob_gzhandler")
放在 PHP 语句链的开头即可。如果 PHP 发出该警告,则意味着该调用尚未开始。Just put
ob_start("ob_gzhandler")
at the start of the chain of PHP statements. If PHP emits that warning it means this call isn't at the start.如果您只想要一些替代方案,您可以在 php.ini 中设置:
http:// /www.php.net/manual/en/zlib.configuration.php
或者在 .htaccess 中(如果您的 PHP 作为 Apache 模块运行):
在这里您可以使用
或
指令将压缩限制为您想要的文件。实际上,您也可以在 PHP 脚本中设置此属性,但我认为它不会起作用:
ini_set('zlib.output_compression', 'On')
...调试问题:如果您在
ob_start()
之前设置header('X-something: x');
,header()
函数是否会导致同样的错误?If you just want some alternatives, you could set in your php.ini:
http://www.php.net/manual/en/zlib.configuration.php
Or in .htaccess if your PHP runs as an Apache module:
Here you can use the
<Files>
or<FilesMatch>
directive to limit compression to the files you want.Actually you can set this property in your PHP script too, but I don't think that it will work:
ini_set('zlib.output_compression', 'On')
...Debug question: If you set
header('X-something: x');
beforeob_start()
, does theheader()
function cause the same error?