note 36909 deleted from function.ob-gzhandler by cmb
| From: | cmb@php.net | Date: | Sun, 01 Mar 2020 09:18:49 +0000 |
| Subject: | note 36909 deleted from function.ob-gzhandler by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-214261@lists.php.net to get a copy of this message | ||
Note Submitter: daijoubuNOSP at Mvideotron dot ca
----
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