PHP Do While Loop With Example

Do...while loop

The do...while statement will execute a block of code at least once - it then will repeat the loop as long as a condition is true.

The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.


Syntax:



Example:

Result:

The number is: 1
The number is: 2
The number is: 3
The number is: 4
The number is: 5 

Read also: