Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the "for(;;)" syntax in this code?

   for(;;)
   {
     if(!$monitor->Throttle($cause))
       die('Fatal error: '.$monitor->error);

     if($cause == THROTTLE_CAUSE_NONE)
       break;

     sleep(60);
   }

i'm a beginner php developer. So how do you read the "for" syntax in previous code. is it valid ?

i got them from http://www.phpclasses.org/blog/post/132-Accelerate-Page-Accesses-Throttling-Background-Tasks-Unusual-Site-Speedup-Techniques-Part-2.html

like image 651
justjoe Avatar asked Nov 28 '22 05:11

justjoe


2 Answers

for(;;) is a C idiom which means "do forever", an infinite loop. This loop will only exit when either the die statement fires (violently) , or the cause is set to THROTTLE_CAUSE_NONE (not so violently).

It's a for loop with no pre-setup, no condition and not post-iteration commands, effectively the same as while true (pseudo-code).

like image 95
paxdiablo Avatar answered Dec 14 '22 01:12

paxdiablo


That's a forever-loop.

like image 28
joni Avatar answered Dec 14 '22 00:12

joni