note 5919 deleted from do..while by jimw
| From: | jimw@php.net | Date: | Thu, 11 Jan 2001 03:08:17 +0000 |
| Subject: | note 5919 deleted from do..while by jimw | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9626@lists.php.net to get a copy of this message | ||
Either camp could be correct depending on what you wanted to do. If you are wanting to escape from
some code which you are only intending on running once, <pre><code>
do{..break..}while(0)
</code></pre> or
<pre><code>
do{..continue..}while(0)
</code></pre> will suffice. If you want to create an infinite loop, and then exit when
some condition is met, you would need to use do{..break..}while(1). <code>break</code>
exits to the next statement after the loop, whereas <code>continue</code> skips the
remainder of this iteration and jumps to the next iteration.<BR>
<BR>
Of course in the latter case it would be much nicer to do a <pre><code>
do..while(condition)
</code></pre> since you are running a test (internal if) every loop anywyas.