VOOZH about

URL: https://www.geeksforgeeks.org/php/php-do-while-loop/

⇱ PHP do-while Loop - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

PHP do-while Loop

Last Updated : 25 Aug, 2022

The do-while loop is very similar to the while loop, the only difference is that the do-while loop checks the expression (condition) at the end of each iteration. In a do-while loop, the loop is executed at least once when the given expression is "false". The first iteration of the loop is executed without checking the condition.

Flowchart of the do-while loop:

👁 Image
 

Syntax:

do {
 // Code is executed
} while (if the condition is true);

Example 1: The following code demonstrates the do..while statement.


Output
10
12
14
16
18

Example 2:


Output
5
10
15
20

Reference: https://www.php.net/manual/en/control-structures.do.while.php

Comment
Article Tags: