菜鸟请教各位压缩的问题
php.ini中设置了
zlib.output_compression = On
<?
//gzdoc.php
ob_start();
ob_implicit_flush(0);
function GzDocOut(){
$gziplevel=9;
$ENCODING = "gzip";
$Contents = ob_get_contents();
$Contents .= "\n<!-- Use compress $ENCODING -->\n";
ob_end_clean();
header("Content-Encoding: $ENCODING");
print pack('cccccccc',0x1f,0x8b,0x08,0x00,0x00,0x00,0x00,0x00);
$Size = strlen($Contents);
$Crc = crc32($Contents);
$Contents = gzcompress($Contents,$gziplevel);
$Contents = substr($Contents, 0, strlen($Contents) - 4);
print $Contents;
print pack('V',$Crc);
print pack('V',$Size);
exit;
}
?>
<?php
//test.php
include_once("./gzdoc.php");
echo "test";
GzDocOut();
?>
但是运行时却出错:
Warning: Cannot add header information - headers already sent by (output started at c:\wwwroot\compress\4.php:29) in c:\wwwroot\compress\gzdoc.php on line 11
?
Fatal error: Call to undefined function: gzcompress() in c:\wwwroot\compress\gzdoc.php on line 15
请问各位大佬,这是什么原因呢?