I am a newbie in php, I have a code
Code: Select all
<?php
ob_start();
for($i=1;$i<=10;$i++)
{
sleep(1);
echo $i;
ob_flush();
}
?>
Thanks
Moderator: General Moderators
Code: Select all
<?php
ob_start();
for($i=1;$i<=10;$i++)
{
sleep(1);
echo $i;
ob_flush();
}
?>
Code: Select all
ob_start();
for($i=1;$i<=10;$i++)
{
sleep(1);
echo $i;
}
ob_flush();
That's what I was thinking, I was just telling him that it would already be more reasonable to flush outside the loop if he tried.SidewinderX wrote:Can this even be done? Won't it just "display" one number per second on the server - then send it to the browser all at once?
Code: Select all
<?php
ob_start();
for($i=1;$i<=10;$i++)
{
sleep(1);
echo $i;
ob_flush();
}
?>
Code: Select all
<?php
ob_start();
for($i=1;$i<=10;$i++)
{
sleep(1);
echo $i;
ob_flush();
}
?>
I am talking about an example showing at http://in3.php.net/manual/en/function.ob-start.php (the 2nd one ) edited by Hudson on 14-May-2009 09:16 , please check and reply me thanksneuroxik wrote:Did you even read what we wrote? You even quoted your own uncorrected code.
hey buddy, he can do so by the following codeneuroxik wrote:That's what I was thinking, I was just telling him that it would already be more reasonable to flush outside the loop if he tried.SidewinderX wrote:Can this even be done? Won't it just "display" one number per second on the server - then send it to the browser all at once?
corecoder wrote: <?php
ob_end_flush();
$totalloops = 10;
for($i=1;$i<=$totalloops;$i++)
{
sleep(1);
echo $i;
flush();
}
?>