开发者

What can be used instead of ob_start("ob_gzhandler");

What 开发者_JAVA技巧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


What worked for me (finally) was to put zlib.output_compression in php.ini and set it to ON, successfuly replacing ob_start("ob_gzhandler");


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.


If you just want some alternatives, you could set in your php.ini:

zlib.output_compression = On

http://www.php.net/manual/en/zlib.configuration.php

Or in .htaccess if your PHP runs as an Apache module:

php_flag zlib.output_compression On

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'); before ob_start(), does the header() function cause the same error?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜