Jump to content

php flush timer


poofried

Recommended Posts

can anyone help me with this script...im trying to create a php flush timer that outputs a different number every second..but its not working. i need the timer to change from 10 to 9 to 8..and just change numbers to the user until 0

 

ob_flush();
flush();

for ($i=10; $i>0; $i--)
{
echo $i-1 . "<br />";
ob_flush();
flush();
sleep(1);
}    

ob_end_flush();

Link to comment
https://forums.phpfreaks.com/topic/177496-php-flush-timer/
Share on other sites

It's not that php can't send portions of a page -- it can.  But that doesn't seem to be what you're trying to do.  Sending parts of an HTTP response is tricky stuff and involves all sorts of intermediary issues that can interfere with your intentions from proxies to the anti-virus someone is using.  If you want a page that sends (IN HTML!)

 

1

2

3

4

 

etc.

 

Yes you can do that, but to what end I don't know, AND it's really tricky to deal with buffering, AND it won't work the way you want for some clients (as mentioned earlier).  For  all those reasons, thorpe is pushing you towards a clientside solution, which could be pure javascript or AJAX if it needs to be something more complicated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935882
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.