Do While Loop
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);
?>
$num=1;
do
{
$num++;
echo $num."<br />";
}
while ($num<10);
?>
Output
23
4
5
6
7
8
9
10
No comments:
Post a Comment