note 102985 added to control-structures.do.while

From: Date: Fri, 18 Mar 2011 13:12:48 +0000
Subject: note 102985 added to control-structures.do.while
Groups: php.notes 
Request: Send a blank email to php-notes+get-177976@lists.php.net to get a copy of this message
If you are trying to use a construct like this: <?php do { // some code to run only one more time if expression is true if ($your_expression == true) continue; } while (false); ?> It will NOT loop as expected, because the continue tries to run the "next" loop, but the expression says just "false" so there is no next loop. The continue exits the while loop. To get around this you may use an other expression, like this <?php do { // some code to run only one more time if expression is true if ($your_expression == true) continue; break; } while (true); ?> or use the goto statement since PHP 5.3. ---- Server IP: 217.160.235.204 Probable Submitter: 84.184.123.87 ---- Manual Page -- http://www.php.net/manual/en/control-structures.do.while.php Edit -- https://master.php.net/note/edit/102985 Del: integrated -- https://master.php.net/note/delete/102985/integrated Del: useless -- https://master.php.net/note/delete/102985/useless Del: bad code -- https://master.php.net/note/delete/102985/bad+code Del: spam -- https://master.php.net/note/delete/102985/spam Del: non-english -- https://master.php.net/note/delete/102985/non-english Del: in docs -- https://master.php.net/note/delete/102985/in+docs Del: other reasons-- https://master.php.net/note/delete/102985 Reject -- https://master.php.net/note/reject/102985 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177976) next »