While Loop
While loop is used to execute a set of statements repeatedly until a condition becomes false.Syntax:
while(condition)
{
// statements that will be executed
}
Example
<?php
$num=1;
while($num<=5) //[While the variable ‘num’ is less than or equal to 5.]
{
echo $num."<br />";
$num++;
}
?>
$num=1;
while($num<=5) //[While the variable ‘num’ is less than or equal to 5.]
{
echo $num."<br />";
$num++;
}
?>
Output
12
3
4
5
No comments:
Post a Comment