While Loops in PHP with example

In PHP, the function of a while loop is to do a task, over and over as long as the specified conditional statement is true.

Syntax :
while (condition)
{
    Program will execute if condition is true;
}

Print some numbers from 1 to 4 using While Loops
<?php
$i = 1;
while($i<=4) {
    echo $i;
}
?>

Output : 1 2 3 4 .