Sunday, April 29, 2012

PHP While Loop Tutorial


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++;
        }
        ?>
Output
1
2
3
4
5

No comments:

Post a Comment