note 36909 modified in function.ob-gzhandler by vincent
| From: | vincent@php.net | Date: | Tue, 28 Oct 2003 07:12:28 +0000 |
| Subject: | note 36909 modified in function.ob-gzhandler by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-59403@lists.php.net to get a copy of this message | ||
So much code...here's a lighter/faster one:
<?php
if ( $do_gzip_compress )
{
$gzip_size = ob_get_length();
$gzip_contents = ob_get_clean(); // PHP < 4.3 use ob_get_contents() + ob_end_clean()
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00",
substr(gzcompress($gzip_contents, 9), 0, - 4), // substr -4 isn't needed
pack('V', crc32($gzip_contents)), // crc32 and
pack('V', $gzip_size); // size are ignored by all the browsers i have tested
}
exit;
?>
I wouldn't recommande using level 9, waste of CPU, something between 1 and 6 would be more
resonable
I have tested without the substr/crc/size and it worked flawlessly in IE5/5.5/6, Opera7.11/7.21,
IE5.5 MAC
--was--
So much code...here's a lighter/faster one:
<?php
if ( $do_gzip_compress )
{
$gzip_size = ob_get_length();
$gzip_contents = ob_get_clean(); // PHP < 4.3 use ob_get_contents() + ob_end_clean()
echo "\x1f\x8b\x08\x00\x00\x00\x00\x00",
substr(gzcompress($gzip_contents, 9) - 4), // substr -4 isn't needed
pack('V', crc32($gzip_contents)), // crc32 and
pack('V', $gzip_size); // size are ignored by all the browsers i have tested
}
exit;
?>
I wouldn't recommande using level 9, waste of CPU, something between 1 and 6 would be more
resonable
I have tested without the substr/crc/size and it worked flawlessly in IE5/5.5/6, Opera7.11/7.21,
IE5.5 MAC
http://www.php.net/manual/en/function.ob-gzhandler.php