PHP Loop not working - refreshes too fast, any idea why?

This is a discussion on PHP Loop not working - refreshes too fast, any idea why? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi folks I have a PHP script that has to stay alive and run a series of checks till the ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-03-2005
cricketunes@yahoo.com
 
Posts: n/a
Default PHP Loop not working - refreshes too fast, any idea why?

Hi folks
I have a PHP script that has to stay alive and run a series of checks
till the user logs out. It comes up as a popup after the user logs in.

I put the whole code inside an endless for loop as follows:
for (;;)
{
<code here>
}

However it is not able to display anything as the loop is too fast.
Is there a way I can get it to loop and also show the page properly?

What would be a good sleep function call to keep the page reasonably
slow and display the other elements on the page?

Thanks,
Cricket

Reply With Quote
  #2 (permalink)  
Old 12-03-2005
Janwillem Borleffs
 
Posts: n/a
Default Re: PHP Loop not working - refreshes too fast, any idea why?

cricketunes@yahoo.com wrote:
> However it is not able to display anything as the loop is too fast.
> Is there a way I can get it to loop and also show the page properly?
>


ob_implicit_flush();
for (;;) {
print "whatever";
}


JW



Reply With Quote
  #3 (permalink)  
Old 12-03-2005
Kimmo Laine
 
Posts: n/a
Default Re: PHP Loop not working - refreshes too fast, any idea why?

<cricketunes@yahoo.com> kirjoitti
viestissä:1133599709.458095.285160@g44g2000cwa.goo glegroups.com...
> Hi folks
> I have a PHP script that has to stay alive and run a series of checks
> till the user logs out. It comes up as a popup after the user logs in.
>
> I put the whole code inside an endless for loop as follows:
> for (;;)
> {
> <code here>
> }
>
> However it is not able to display anything as the loop is too fast.
> Is there a way I can get it to loop and also show the page properly?
>
> What would be a good sleep function call to keep the page reasonably
> slow and display the other elements on the page?



umm... sleep()?
http://www.php.net/manual/en/function.sleep.php

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <antaatulla.sikanautaa@gmail.com.NOSPAM.invalid>


Reply With Quote
  #4 (permalink)  
Old 12-04-2005
Sean
 
Posts: n/a
Default Re: PHP Loop not working - refreshes too fast, any idea why?

Basically it's a really bad bad bad idea writing infinite loops like
this for any scenario.

for (;;)
{
<code here>
}

This is a waste of system resources, and its only going to work if you
set the timeout limit of this page to be infinite (or some really big
number, which you don't want to do! its not going to work and if
there was any significant amount of hits to the page apache would
probably give up the ghost).

You want to scrap this and look at doing something with a client side
language like JavaScript.

Reply With Quote
  #5 (permalink)  
Old 02-06-2006
Jim Michaels
 
Posts: n/a
Default Re: PHP Loop not working - refreshes too fast, any idea why?


"Sean" <oreilly.sean@gmail.com> wrote in message
news:1133704574.719424.203610@z14g2000cwz.googlegr oups.com...
> Basically it's a really bad bad bad idea writing infinite loops like
> this for any scenario.
>
> for (;;)
> {
> <code here>
> }
>
> This is a waste of system resources, and its only going to work if you
> set the timeout limit of this page to be infinite (or some really big
> number, which you don't want to do! its not going to work and if
> there was any significant amount of hits to the page apache would
> probably give up the ghost).
>
> You want to scrap this and look at doing something with a client side
> language like JavaScript.
>


I'm probably late in jumpin in here, but think of the poor user. they'll
never get their browser back.


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:09 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0