Page 1 of 1
php infinite loop
Posted: Wed Mar 30, 2011 9:58 pm
by Klown
Will an infinite loop in php eventually timeout ? im not sure because ive never done this before.
if i run a code similar to the example below, would it timeout on an error eventually?
example:
Code: Select all
$i=0;
while($i = 0){
sleep(2000);
}
-klown
Re: php infinite loop
Posted: Wed Mar 30, 2011 10:12 pm
by Jackolantern
While I have never had a reason to run an infinite loop in production and don't know for sure, I believe some Comet techniques rely on infinite, or at least long running loops in PHP, so I would assume that they can at least run for a long time.
Re: php infinite loop
Posted: Thu Mar 31, 2011 1:07 am
by PaxBritannia
It depends on your server's settings. There is a setting that will eventually timeout the script, so you'll have to modify that setting.
On a physical level though, sometime or later, the server will go down. Maybe cloud hosting?
pax.