首页  >  文章  >  后端开发  >  PHP输出gzip压缩

PHP输出gzip压缩

WBOY
WBOY原创
2016-07-29 09:01:121249浏览

<code><span><span>function</span><span>ob_gzip</span><span>(<span>$content</span>)</span>{</span><span>if</span>(!headers_sent()&&extension_loaded(<span>"zlib"</span>)&&strstr(<span>$_SERVER</span>[<span>"HTTP_ACCEPT_ENCODING"</span>],<span>"gzip"</span>)){
        <span>$content</span> = gzencode(<span>$content</span>,<span>9</span>);
        header(<span>"Content-Encoding: gzip"</span>);
        header(<span>"Vary: Accept-Encoding"</span>);
        header(<span>"Content-Length: "</span>.strlen(<span>$content</span>));
    }
    <span>return</span><span>$content</span>;
}
ob_start(<span>'ob_gzip'</span>); <span>//函数名</span><span>echo</span><span>"这是测试字符串这是测试字符串这是测试字符串"</span>;
ob_end_flush();</code>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了PHP输出gzip压缩,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn