03
Feb
2011
2011
PHP While Loop
Posted in: PHP
No Comments

while in PHP is used for looping. It tells PHP to execute the nested statement(s) repeatedly, as long as the while expression evaluates to TRUE.
Syntax of a while loop
While(conditions)
{
// This code to execute until the conditions
// provided no longer evaluates to true
}
Example of a while loop
We want to print number from 1 to 100.
<?php
$a = 1;
while($a != 101)
{
echo "$a";
$a = $a + 1;
}
?>










