|
PHP wait() and flush() not working
I'm trying to use Wait and Flush, but the page displays blank, then waits the appropriate time and displays everything.
The below script works properly on another web site so I know my browser is not the issue. It must be a setting in php.ini. I googled it and found all kinds of things, output_buffering, gzip etc.
I do not know enough about php.ini to know what to change, nor do I have access to it and I don’t want my provider changing things for testing.
Does someone have experience with this? Or is there a way to override my php.ini? I tried .htaccess but with no results.
Any help would be appreciated.
error_reporting(E_ALL);
// SIMULATE A LONG-RUNNING JOB WITH INTERMITTENT BROWSER OUTPUT
function my_echo($str, $pad=' ')
{
$str = str_pad($str, strlen($str) + 512, $pad);
echo $str;
echo PHP_EOL;
flush();
}
// TEST THE URL ARGUMENT FOR "b=y" AND OPTIONALLY START THE OUTPUT BUFFER
$b = (!empty($_GET["b"])) ? $_GET["b"] : NULL;
if ($b == 'y') ob_start();
// RUN THE TEST MESSAGES WAITING BETWEEN THE MESSAGES
my_echo("<br/>Hello #1");
sleep(1);
my_echo("<br/>Hello #2");
sleep(2);
my_echo("<br/>Hello #3");
sleep(3);
my_echo("<br/>Hello #4");
sleep(4);
my_echo("<br/>Hello #5");
sleep(1);
my_echo("<br/>Hello #6");
|