php-zlib压缩支持获胜';不起作用


php zlib compression support won't work

如果我在php.ini中设置zlib压缩支持,似乎真的不起作用。

zlib.output_compression = On
; http://php.net/zlib.output-compression-level
zlib.output_compression_level = -1
; You cannot specify additional output handlers if zlib.output_compression
; is activated here. This setting does the same as output_handler but in
; a different order.
; http://php.net/zlib.output-handler
;zlib.output_handler =

我使用的是php-5.3.9

我一直在用以下php代码进行测试,我必须说我不是专业人士,但似乎不起作用。

<?php
$filename = tempnam('/tmp', 'zlibtest') . '.gz';
echo "<html>'n<head></head>'n<body>'n<pre>'n";
$s = "Only a test, test, test, test, test, test, test, test!'n";
// open file for writing with maximum compression
$zp = gzopen($filename, "w9");
// write string to file
gzwrite($zp, $s);
// close file
gzclose($zp);
// open file for reading
$zp = gzopen($filename, "r");
// read 3 char
echo gzread($zp, 3);
// output until end of the file and close it.
gzpassthru($zp);
gzclose($zp);
echo "'n";
// open file and print content (the 2nd time).
if (readgzfile($filename) != strlen($s)) {
        echo "Error with zlib functions!";
}
unlink($filename);
echo "</pre>'n</body>'n</html>'n";
?>

没有输出

zlib输出处理程序与gz文件函数无关。

所以有其他问题,打开error_reporting

否则,显示的代码工作正常。"无输出"行为是不可再现的。