PHP do while loop

“do while” loop is almost similar to “while” loop in PHP. The expression with “do while” statement will be executed only at the end of each iteration. So at the first iteration the code will execute before checking the expression. So in the do while loop the first iteration will surely executed .

This is the structure of a PHP do while loop

// Operation Statements
} while (expression);

See the sample PHP program with “do while” statement

$a = 0;
echo $a." ";
}while ($a < 3);

Its output will be
0 1 2