Problems with output buffering and gzcompress()
| From: | Chris Lee | Date: | Fri, 05 Jan 2001 02:49:48 +0000 |
| Subject: | Problems with output buffering and gzcompress() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-32806@lists.php.net to get a copy of this message | ||
heres whats not working, I can get php to compress my output buffer but I
cant get my function to work in all browsers.
//--------------------------------------------------------------------------
---------
header("Content-Encoding: gzip");
ob_start("compress_output");
//--------------------------------------------------------------------------
---------
echo "hello? what? why do you say it like that?<br>\n";
ok there is the code
Opera 5.01 - displays page ok, but gives a "data corrupt error"
IE 5.5 - displays blank page
Lynx 2.8.3 - everything works
Amaya 4.2.1 - everything works
Netscape 6 - everything works
//--------------------------------------------------------------------------
---------
function compress_output($output)
{
$output = gzcompress($output);
$size = strlen($output);
$crc = crc32($output);
$output = substr($output, 0, strlen($output) - 4);
$data = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$data .= $output;
$data .= pack("V",$crc);
$data .= pack("V",$size);
return $data;
}
//--------------------------------------------------------------------------
---------
Opera 5.01 - GPF's
IE 5.5 - everything works
Lynx 2.8.3 - everything works
Amaya 4.2.1 - everything works
Netscape 6 - everything works
//--------------------------------------------------------------------------
---------
function compress_output($output)
{
$output = gzcompress($output);
$size = strlen($output);
$crc = crc32($output);
$data = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$data .= $output;
return $data;
}
//--------------------------------------------------------------------------
---------
Any idea's ? With one IE doesnt work, with the other Opera doesnt work.
And all you who say "no one uses Opera" dont bother saying it. :)
Chris Lee
Mediawaveonline.com