Saturday, 10 August 2013

PHP flush() function not working

PHP flush() function not working

I am trying to echo output of script while its still running. gzip
compression is off. I am using Firefox 22
In php.ini i set following values :
default_charset = "utf-8"
zlib.output_compression_level = -1
zlib.output_compression = Off
output_buffering = 0
implicit_flush = true
I am using this example :
<?php
ob_end_flush ();
//start buffering
ob_start ();
echo str_pad ( '', 1024 ); // minimum start for Safari
for ( $i = 10; $i > 0; $i --) {
echo str_pad ( "$i<br>\n", 8 );
ob_flush ();
flush ();
sleep ( 1 );
}
?>
i also tried to replace
echo str_pad ( '', 1024 );
with
echo str_pad ( '', 4096 );
but it didnt work. There are lots of topic about this issue but there is
no guaranteed way to make this work and other solutions didnt work for me.
Is there any method to debug this issue and find the solution?
I dont want to use ajax because script also needs to be able to used by cron.

No comments:

Post a Comment