Php While loop

While loop works same the other programming language. In the while loop, If the expression’s result is true, the loop will run all the statements inside it. If the result is false, however, the loop will end and pass the program control to the statements after it.

Syntax:-


while (expression)
statement

Example:-


<?php
$i=1;
while($i<5){

	print $i."<br/>";
	$i++;
}
?>
1
2
3
4

Try it Yourself