Home > Backend Development > PHP Tutorial > 请大伙儿帮忙看一下这段代码为什么会出错

请大伙儿帮忙看一下这段代码为什么会出错

WBOY
Release: 2016-06-13 11:52:46
Original
1095 people have browsed it

请大家帮忙看一下这段代码为什么会出错
//调用一个函数名为ob_gzip的内容进行压缩
ob_start('ob_gzip');
//输出内容
ob_end_flush();
//这是ob_gzip函数

function ob_gzip($content)
{
if(!headers_sent()&&extension_loaded("zlib")
&&strstr($_SERVER["HTTP_ACCEPT_ENCODING"],"gzip"))
{
$content = gzencode($content." n//此页已压缩",9);
header("Content-Encoding: gzip");
header("Vary: Accept-Encoding");
header("Content-Length: ".strlen($content));
}
return $content;
}

浏览器告诉我,说不支持的编码格式,请问我要怎么做呢?谢谢大家的帮忙,万分感谢!!
------解决方案--------------------

header("content-type:text/html; charset=xxx"); 
Copy after login
XXX可以是utf-8 也可以是gb2312 具体是什么得看你文件的编码了
------解决方案--------------------
具体看下你的文件编码

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template