I want output echo in browser (every time) before sleep function execute.
following code is not working
set_time_limit(0);
ob_implicit_flush(1);
ob_start();
echo "Start<Br>";
ob_flush();
for($i=0;$i<10;$i++){
$randSlp=rand(1,3);
//echo str_repeat(" ", 1024);
echo "Sleeping for ".$randSlp." second. ";
ob_flush();
sleep($randSlp);
}
ob_end_flush();
if uncomment str_repeat
function than in browser
First time :
Start
Sleeping for 1 second.
Sleeping for 3 second.
Second time : Sleeping for 2 second.
Sleeping for 2 second.
and continue...
is possible echo one by one without str_repeat() function, why output doesn't display every time.
ob_flush()
?ob_flush();
after echo, or need to put other place