100高分请教了!!!解决后马上给分!!!急!!! 你的代码我不是很懂,我觉得应该在apache的配置文件中注册mime类型text/zip gzip 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果在linux中,编译php的时候要加参数“--with-zlib=yes”。这样php才可以支持gzip压缩输出。如果在windows平台上,在php.ini中的extension中打开“;extension=php_zlib.dll”把分号去掉。如果失败,则下载php for windows的完全包。如果不打开这个模块,当然就会出现你的问题了。 多谢各位答复!这是一段将页面压缩书出的代码,所以使用了zlib库中的函数zlib当然支持了,否则我这段代码汇报错的!而且我还使用了function_exists('gzcompress')监测这个压缩函数的存在。问题是在浏览器这边,它不给压缩输出后的页面解压缩显示,而是当作了一个文件下载,问题可能是出在header("Content-Encoding: $ENCODING");函数里,大家再帮忙想想办法吧,真的很急,我试过无数方法都不行了。 header里加上输出:Content-Type: text/html 给你个例子:把你的代码加到中间省略处。<?if (function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip){ ob_start();}?><html><head><meta content="text/html; charset=windows-1252" http-equiv="Content-Type"><meta http-equiv="MSThemeCompatible" content="Yes"><link rel="stylesheet" href="../include/style.css"><body leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">....</BODY></HTML><?php if (function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip) { if (strpos(" ".$HTTP_ACCEPT_ENCODING,"x-gzip")) { $encoding = "x-gzip"; } if (strpos(" ".$HTTP_ACCEPT_ENCODING,"gzip")) { $encoding = "gzip"; } if ($encoding) { $text = ob_get_contents(); ob_end_clean(); header("Content-Encoding: $encoding"); $size = strlen($text); $crc = crc32($text); $returntext = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; $returntext .= substr(gzcompress($text,$level),0,-4); $returntext .= pack("V",$crc); $returntext .= pack("V",$size); echo $returntext; exit; } } 上面的$nozip为控制参数,可以先去掉不要。 echo $ENCODING看看最后到底输出的是什么 require中使用绝对路径的问题:常量重定义,变量覆盖,重调用增加开销。 请教一个mysql索引的问题 一个nginx重写的问题 PHP怎么给JS变量符值? 哪个php的编译器更好用? 如何控制输入的数字并将其分隔开 小妹请教师哥往div里赋值如何进行! apache伪静态配置求助 感谢 问一个关于首饰的正则表达式 tp3.2.3自动成功后自动跳转,后面什么代码都没写,页面自己跳转 请教php高手啊看看我的这个问题是怎么会事? 急 急 急 急 急 急 在线的进来看看啦?有问题!!!
Content-Type: text/html
<?
if (function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip){
ob_start();
}
?>
<html><head>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<meta http-equiv="MSThemeCompatible" content="Yes">
<link rel="stylesheet" href="../include/style.css">
<body leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">
.
.
.
.
</BODY></HTML>
<?php if (function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip) {
if (strpos(" ".$HTTP_ACCEPT_ENCODING,"x-gzip")) {
$encoding = "x-gzip";
}
if (strpos(" ".$HTTP_ACCEPT_ENCODING,"gzip")) {
$encoding = "gzip";
} if ($encoding) {
$text = ob_get_contents();
ob_end_clean(); header("Content-Encoding: $encoding"); $size = strlen($text);
$crc = crc32($text); $returntext = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$returntext .= substr(gzcompress($text,$level),0,-4);
$returntext .= pack("V",$crc);
$returntext .= pack("V",$size); echo $returntext;
exit;
}
}