note 102985 deleted from control-structures.do.while by cmb
| From: | cmb@php.net | Date: | Sun, 04 Dec 2016 12:25:08 +0000 |
| Subject: | note 102985 deleted from control-structures.do.while by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208213@lists.php.net to get a copy of this message | ||
Note Submitter: david dot schueler at tel-billig dot de
----
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.