03
Feb
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;
}
?>

About the Author

Name: Ravi Shekhar
Hi, I love designing WordPress Themes and Drupal Themes.

Share this post

Twitter Facebook Google Buzz Digg StumbleUpon Delicious Technorati

Leave a Reply