note 74419 added to control-structures.do.while

From: Date: Tue, 10 Apr 2007 22:36:13 +0000
Subject: note 74419 added to control-structures.do.while
Groups: php.notes 
Request: Send a blank email to php-notes+get-125272@lists.php.net to get a copy of this message
There is one major difference you should be aware of when using the do--while loop vs. using a simple while loop: And that is when the check condition is made. In a do--while loop, the test condition evaluation is at the end of the loop. This means that the code inside of the loop will iterate once through before the condition is ever evaluated. This is ideal for tasks that need to execute once before a test is made to continue, such as test that is dependant upon the results of the loop. Conversely, a plain while loop evaluates the test condition at the begining of the loop before any execution in the loop block is ever made. If for some reason your test condition evaluates to false at the very start of the loop, none of the code inside your loop will be executed. ---- Server IP: 69.39.81.135 Probable Submitter: 209.239.37.219 ---- Manual Page -- http://www.php.net/manual/en/control-structures.do.while.php Edit -- https://master.php.net/note/edit/74419 Del: integrated -- https://master.php.net/note/delete/74419/integrated Del: useless -- https://master.php.net/note/delete/74419/useless Del: bad code -- https://master.php.net/note/delete/74419/bad+code Del: spam -- https://master.php.net/note/delete/74419/spam Del: non-english -- https://master.php.net/note/delete/74419/non-english Del: in docs -- https://master.php.net/note/delete/74419/in+docs Del: other reasons-- https://master.php.net/note/delete/74419 Reject -- https://master.php.net/note/reject/74419 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#125272) next »