php infinite loop

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
Klown
Posts: 90
Joined: Tue Feb 22, 2011 5:59 am

php infinite loop

Post 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
if( $myGames != "Crap" ) {
  • please_donate( $money );
} else {
  • just_enjoy();
}
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: php infinite loop

Post 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.
The indelible lord of tl;dr
User avatar
PaxBritannia
Posts: 680
Joined: Sun Apr 18, 2010 1:54 pm

Re: php infinite loop

Post 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.
Post Reply

Return to “Beginner Help and Support”