|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-09-01 11:07 UTC] wico at cnh dot nl
Hiya
I want to compress webpages for clients that support it
$data is a whole html page
but:
This works:
function Compress ($data) {
$fp = fopen("/tmp/tempje", "w");
fputs($fp, $data);
fclose($fp);
$data2 = `cat /tmp/tempje |/usr/bin/gzip -f`; */
Header("Content-Type: text/html");
Header("Content-Encoding: gzip");
echo($data2);
}
this doesn't:
function Compress ($data) {
$data = gzcompress($data);
Header("Content-Type: text/html");
Header("Content-Encoding: gzip");
echo($data2);
}
Anyone can explain this?
Greetz,
Wico
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 00:00:01 2025 UTC |
Hiya As i allready said in my email thats a typo. This works: function Compress ($data) { $fp = fopen("/tmp/tempje", "w"); fputs($fp, $data); fclose($fp); $data2 = `cat /tmp/tempje |/usr/bin/gzip -f`; Header("Content-Type: text/html"); Header("Content-Encoding: gzip"); echo($data2); } this doesn't: function Compress ($data) { $data = gzcompress($data); Header("Content-Type: text/html"); Header("Content-Encoding: gzip"); echo($data); }I guess you should use gzopen("php://stdout","w") instead, because gzcompress doesn't have all gzip file headers too. In other words, gzcompress and gzopen/gzwrite are different functions, and in zlib too.