note 90073 deleted from control-structures.if by peehaa
| From: | peehaa@php.net | Date: | Wed, 12 Oct 2016 13:13:20 +0000 |
| Subject: | note 90073 deleted from control-structures.if by peehaa | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206850@lists.php.net to get a copy of this message | ||
Note Submitter: strata_ranger at hotmail dot com
----
Although most programmers are aware of this already, if for whatever reason you need to
'break' out of an if() block (which, unlike switch() is not considered a looping
structure) just wrap it in an appropriate looping structure, such as a do-while(false):
<?php
do if ($foo)
{
// Do something first...
// Shall we continue with this block, or exit now?
if ($abort_if_block) break;
// Continue doing something...
} while (false);
?>