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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
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 |
|
|||
|
<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> |
|
|||
|
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. |
|
|||
|
"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. |