php zlib压缩支持不起作用

时间:2012-01-16 22:08:29

标签: zlib php

如果我在我的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";

?>

没有输出

1 个答案:

答案 0 :(得分:0)

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

所以还有其他问题,请启用error_reporting

否则显示的代码工作正常。 “无输出”行为不可重复。

相关问题