note 43977 deleted from control-structures.continue by tomsommer

From: Date: Sun, 11 Jul 2004 00:16:26 +0000
Subject: note 43977 deleted from control-structures.continue by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73019@lists.php.net to get a copy of this message
Note Submitter: tom@soosed.com ---- Watch out while using continue and a do loop. When there is a continue inside a do while structure, it does not automatically return to the top of the loop. It tests the exit condition before it does this. $x = 0; do { $x++; if ($x == 100) continue; echo $x; } while ($x < 100) In this case, the loop would not do a 101th iteration. The exit condition is still tested even with a continue. This may seem obvious and it is a rare occurence, but in larger coding structures, with many variables, it may be hard to notice.

« previous php.notes (#73019) next »