Forum Moderators: coopster

Message Too Old, No Replies

How to compress HTML with PHP with several flush()

gzencode() seems to work only once - is there a workaround?

         

moremoneytome

8:12 am on Apr 30, 2004 (gmt 0)

10+ Year Member



The following code doesn't work. "line 2" is never printed. Do you know why? Is there a workaround?

I want to be able to print compressed HTML in blocks. Not everything at the same time.


<?
function compress_output($output) {
return gzencode($output);
}

if (stristr(getenv('HTTP_ACCEPT_ENCODING'), 'gzip')) {
ob_start("compress_output");
header("Content-Encoding: gzip");
} else {
ob_start();
}

echo "line 1<br>";
ob_flush();flush();
echo "line 2<br>";
?>

hakre

2:16 pm on Apr 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



have you tried to add
ob_flush();flush();
after the last line, too? :

[i]...[/i]
ob_flush();flush();
echo "line 2<br>";
[b]ob_flush();flush();[/b]
?>

--hakre

moremoneytome

6:47 am on May 3, 2004 (gmt 0)

10+ Year Member



Yes! That doesn't help...