Logo


PHP Loop Do While



Loop Do While

Do while loop allows you to execute an action at least one time no matter if it is true or false. The loop executes round and round while the condition is true. When the condition becomes false, the loop breaks out or terminates of the loop.

Syntax:

do
{
// statements that will be executed
}
while(condition)

Example

<?php
$num
=1;
do
  {
   
$num++;
   echo 
$num."<br />";
  }
  while (
$num<10);
?>

Output

2
3
4
5
6
7
8
9
10



If you like this Article, Share and Enjoy



See Also
For Loop
Foreach Loop
While Loop