In PHP, the function of a do-while loop is to do a task, over and over as long as the specified conditional statement is true. . But do-while loop always executes its block of code at least once.
Syntax :
do
{
Program will execute if condition is true or at first time;
}
while (condition);
<?php
$i = 1;
do {
$i++
echo $i;
}
while($i<=4)
?>
Output : 2 3 4 5
<?php
$i = 0;
do {
echo $i;
}
while($i>1)
?>
Output : 0