PHP While Loop

tutorial and example
tutorial and example

PHP while loop is used to run the same block of code until a condition is met. It should be used if number of iteration it not known.

Syntax:

Example:

<?php

$n=1;

while($n<=5){

echo “$n<br/>”;

$n++;

}

?>

Output

1

2

3

4

5