phpicoder Nov 2, 2021 php

Hi guys, In this tutorial we will learn how to use while Loop using PHP.

The while loop is used when you  wont to the loop to execute and continue executing while the specified condition is true. 
While the loop is also called the entry control loop, becuse in while loop the first check condition an then executed the code.

Syntax:
while(condition){
    // Code to be executed
}

Example: print 1 to 5 using while loop.

<?php
	  $i = 1;

	  while($i <= 5) {
	    echo "The number is: $1 
";
	    $i++;
	  }
	?>
Output:
The number is: 1
The number is: 2
The number is: 3
The number is: 4
The number is: 5

I hope this tutorial help for you.