PHP do while loop

The do-while loops are very similar to while loops, do-while loops checked the expression at the end of iteration.

Syntax of do-while loop

do
{
 //execute the statement; 
}
while(expression)

Example- 1

$i = 1;
do {
    echo $i++;
} while ($i < 5);
//output: 1234

Example- 2

The first iteration of a do-while loop is guaranteed to run because condition is checked at last

$i = 1;
do {
    echo $i;
} while ($i > 1);
//output: 1