Re: Compression
| From: | Andreas Pour | Date: | Sun, 23 Jul 2000 21:29:01 +0000 |
| Subject: | Re: Compression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7784@lists.php.net to get a copy of this message | ||
Matthias Schniedermeyer wrote:
>
> #include <hallo.h>
>
> Today i look in the output of "phpinfo();" and found out that all of the
> popular Browsers have "ACCEPT_ENCODING=gzip".
>
> So i tried it and compressed index.html and feed "index.html.gz" into
> Netscape 4.72/IE 5.0/Opera 4.0 and all of them worked correct.
>
> I looked into the compression-paragrah of the manual but couldn't find a
> way to say php to compress all the output before sending it to the
> browser.
>
> Do i have tomatoes on my eyes or does the function not exist?
Hi,
There is not one function to do it. You have to buffer the output, then
right before exitting compress and send it:
Your prepend script:
if (gzip encoding accepted)
ob_start();
Your postpend script:
if (gzip encoding accepted)
{
$data = ob_get_string();
ob_end_flush();
echo gzcompress($data);
}
Ciao,
Andreas