PDA

View Full Version : zlib? gzip?



crj
April 24th, 2002, 17:49
how do i use zlib or gzip to compress php scripts on my site?

do i put something inside htaccess or something?

wm2k1
April 24th, 2002, 19:08
edit ur php.ini file
extension=php_zlib.dll

crj
April 27th, 2002, 21:28
thats it?

and it'll compress automatically by itself?

AcuNett
April 29th, 2002, 22:01
Are you talking about *nix or Windows?

is0lized
April 29th, 2002, 22:09
note it will take up more cpu usage

GregT
April 29th, 2002, 22:36
Originally posted by crj
how do i use zlib or gzip to compress php scripts on my site?

do i put something inside htaccess or something?

is it running on ur machine or sum1 else

AlieXai
April 30th, 2002, 09:04
> how do i use zlib or gzip to compress php scripts on my site?

Put this at the top of your (php) scripts and, if your server supports zlib/gzip...



<?php
$phpver = phpversion();
if($phpver >= '4.0.4pl1')
{
if(extension_loaded('zlib'))
{
ob_start('ob_gzhandler');
}
}
else if($phpver > '4.0')
{
if(strstr($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip'))
{
if(extension_loaded('zlib'))
{
ob_start();
ob_implicit_flush(0);
header('Content-Encoding: gzip');
}
}
}
?>