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

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -