Certified PHP Developer Learning Resources Do while

Do while
 


The Do...While statements are similar to While statements, except that the condition is tested at the end of each iteration, rather than at the beginning. This means that the Do...While loop is guaranteed to run at least once. The Do...While loop syntax is as follows:
do
{
   code to be exected;
}
while (condition);

The example below will increment the value of i at least once, and it will continue incrementing the variable i as long as it has a value of less than or equal to 10:
$i = 0;
do {
   echo "The number is ".$i."
";
   $i++;
}
while ($i <= 10);
?>

 

 For Support