菜鸟请教各位压缩的问题

kavlenny 2003-12-29 03:27:07
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

请问各位大佬,这是什么原因呢?
...全文
82 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Fred_Mark 2003-12-29
  • 打赏
  • 举报
回复
学习
kavlenny 2003-12-29
  • 打赏
  • 举报
回复
谢谢 xuzuning(唠叨) 大哥提醒,去掉这些注释就过去了,可以是页面上什么都没有。。
不是有一个"test"echo出来了吗?怎么不见了?
kavlenny 2003-12-29
  • 打赏
  • 举报
回复
我哪里什么都没有?只是gzdoc.php中的文件,然后用/* */屏蔽掉了


4.php中所有的代码

<?
/*
//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();
?>
xuzuning 2003-12-29
  • 打赏
  • 举报
回复
贴出4.php前30行代码

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧