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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.