note 10402 added to gzcompress
| From: | gvirgo at mithril dot com | Date: | Tue, 02 Jan 2001 04:14:39 +0000 |
| Subject: | note 10402 added to gzcompress | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9237@lists.php.net to get a copy of this message | ||
>>Netscape 4 (on all platforms[?]), IE4/IE5 on the Mac do NOT support
>>gz-compression. Email me if you want to know more.
As a matter of fact, Netscape 4.7x on Win32 DOES support gz-compression. Calling the following
script in my auto_prepend directive seems to work fine. The script is taken from the Output
Buffering article on Zend.com (http://www.zend.com/zend/art/buffering.php). As noted in the
article, it only works with PHP 4.0.4 and higher.
<?php
// function to compress the output buffer in preparation for transmission to client
function compress_output($output) {
// compress and return the output buffer
return gzencode($output);
}
// Check if the browser supports gzip encoding, HTTP_ACCEPT_ENCODING
if (strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip')) {
// Start output buffering, and register compress_output()
ob_start("compress_output");
// Tell the browser the content is compressed with gzip
header("Content-Encoding: gzip");
}
?>
http://www.php.net/manual/function.gzcompress.php