note 8553 deleted from function.gzcompress by nlopess
| From: | nlopess@php.net | Date: | Sun, 14 Nov 2004 11:15:34 +0000 |
| Subject: | note 8553 deleted from function.gzcompress by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80491@lists.php.net to get a copy of this message | ||
Note Submitter: @boas.anthro.mnsu.edu
----
As a precaution, the gzcompress() and gzuncompress() functions do not actually use gzip style
compression -- rather, they use compress or deflate.
This will greatly affect compression of output from PHP scripts. Assuming that you want to
optionally compress data from your PHP script to the browser (if they support it), then you must not
use this function.
if (browser_supports_gzip)
{
ob_start();
}
... you output stuff here ...
if (browser_supports_gzip)
{
Header("Content-Encoding: gzip");
// THIS DOES NOT WORK
echo gzcompress(ob_get_contents());
ob_end_clean();
}
If gzcompress gets changed in the future (4.0.3?) then outputting compressed output from PHP scripts
will be much easier. Until then, you must replace the single line above with several others --
tempnam() to find a temporary file, gzopen() it, write the contents of the buffer to the compressed
file, close the file, open the file as binary, write the output to the browser, close the file,
delete the temporary file.
I sincerely hope that either the documentation is changed to reflect that gzip style compression is
not used, or maybe gzcompress()'s code gets changed in PHP.