PHP的Zlib跟gzhandle

WBOY
Release: 2016-06-13 11:00:23
Original
793 people have browsed it

PHP的Zlib和gzhandle

请高手无视内容.....

纯笔记

PHP的压缩传输可以使用php.ini中设置Zlib.output_compression=on,此时所有的PHP输出都会经过压缩 或者修改程序对指定要压缩的程序进行ob_start("ob_gzhandler");来实现压缩。

AMFPHP使用gzhandler压缩。
压缩的原理都一样,都是使用Zlib extension来操作,所以一定要load zlib.so,两种方式在同一个页面只能任选其一,否则会冲突。
使用ob_gzhandler的话实际调用ext/zlib/zlib.c的ob_gzhandler,来检测浏览器支持的压缩类型,执行gzip就用gzip压缩或者deflate.

?

ob_start();
ob_start('ob_gzhandler');
ob_end_flush();
header("Content-length: " . ob_get_length());
ob_end_flush();

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!