do-while

PHP do-while loop are very similar to while loop.
Only one difference in do-while, loop condition is checked at end of each iteration.
Whereas, in while loop condition is checked at beginning of loop.
Also, in do-while, loop is execute at onces without checking condition.
Output of do-while loop and while loop is same.

 

Syntax of PHP do-while

Following is given a general syntax of do-while loop in PHP:

 

Flowchart of PHP do-while loop

php do-while loop
 

Example

Output:

Help others by sharing the content!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.