PHP while loop

The while loop executes a block of code as long as the specified expression is true.

Syntax of while loop

while(expression)
{
	//execute the statement; 
}

Example- 1

$i = 1;
while ($i <= 5) {
    echo $i++;  
}
//output: 12345