poofried Posted October 13, 2009 Share Posted October 13, 2009 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(); Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/ Share on other sites More sharing options...
poofried Posted October 13, 2009 Author Share Posted October 13, 2009 BUMP Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935875 Share on other sites More sharing options...
trq Posted October 13, 2009 Share Posted October 13, 2009 You'll need to do this client-side using javascript, not php. Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935876 Share on other sites More sharing options...
poofried Posted October 13, 2009 Author Share Posted October 13, 2009 why? i thoght php could do anything Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935879 Share on other sites More sharing options...
gizmola Posted October 13, 2009 Share Posted October 13, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935882 Share on other sites More sharing options...
poofried Posted October 13, 2009 Author Share Posted October 13, 2009 so php suck? Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935885 Share on other sites More sharing options...
PFMaBiSmAd Posted October 13, 2009 Share Posted October 13, 2009 Only when you attempt to get a web server to do something it was not designed to do. Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935886 Share on other sites More sharing options...
gizmola Posted October 13, 2009 Share Posted October 13, 2009 so php suck? Yes, I'm sure that Yahoo and Google and Facebook and (10 million other websites) agree with you that PHP sucks, although they continue to use it. If only you were there to share your insights with them. Quote Link to comment https://forums.phpfreaks.com/topic/177496-php-flush-timer/#findComment-935892 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.