发新话题
打印

php内置的压缩函数 ?? ob_gzhandler()

php内置的压缩函数 ?? ob_gzhandler()

ob_gzhandler()是PHP4.0.4以后内置的压缩函数,下面是网上对于这个函数的介绍文章: ----------------------- 这个输出缓冲处理的方法很好,并且不会为服务器带来额外的系统开销。我十分建议你使用这种方法。它的改变可以用以下的例子说明,如果客户使用的是28.8K的modem的话,经过这个处理,他将会认为突然间换成了一个ISDN接入一样。要注意的一点是:Netscape Communicator并不支持图象的压缩,所以将显示不出来。因此除非你的客户全部使用Internet Explorer,否则你必须禁止压缩jpeg和gif图象。其它文件的压缩应该没有问题,但是我建议你最好测试一下,特别是浏览器使用了不常见的插件或者是少人用的浏览器。 ----------------------- 这个函数的使用不能:ob_start("ob_gzhandler"); 而是必须自己写一个function来把他包装起来,因为ob_gzhandler有第二个参数,他的解释在:http://www.php.net/manual/fr/ref.zlib.php#56216 如下: If you need to compress data and send it as "Content-disposition: attachment" and on-the-fly to the client due to the size for example (40Mb) here's a dirty trick using ob_gzhandler() Keep in mind that $str is the content to output. When you start the output call Then to output any further content And to close the output

TOP

发新话题