note 43977 added to control-structures.continue

From: Date: Sun, 11 Jul 2004 00:14:28 +0000
Subject: note 43977 added to control-structures.continue
Groups: php.notes 
Request: Send a blank email to php-notes+get-73018@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/control-structures.continue.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43977 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43977&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43977&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#73018) next »