Press "Enter" to skip to content

phpwhileloops

PHP while loops

The while loop allows you to repeat a block of code until the condition is TRUE.

SYNTAX


while (condition ) {
code to be executed;
}
 
 

Example for PHP while loops

<?php

$n=1;
echo “while loop example”;
while($n<=10)
{
echo “The Number is $n”;
$n=$n+1;
}
?>