What is the Advantage of using Do While PHP -
this question has answer here:
i searching advantage of using while, of blogs , tutorials depends on requirement, without there advantage while ?
<?php $i = 0; { echo $i; } while ($i > 0); ?>
there's no advantage. while pre-conditioned loop, , do..while post-conditioned loop. means - in while condition checked before iteration, , in do..while - after iteration.
therefore, in do..while loop body executed at least once - can not used if you're iterating something, can have 0 repeating (for example, count of rows in select database).
note, due structured program theorem program written if , while. so, in general, there's no need in do..while statement. can replace while.
Comments
Post a Comment