PHP While loop


A while loop is a control statement using which the programmer can give instructions to the computer to execute a set of statement repeatedly as long as specified condition is satisfied. Ones the specified condition is false control comes out of the loop.
Syntax:-
         initialization
         while(condition)
            {
                  statement.....
                  updating
            }

Flowchart:-


while-loop

W.A.P to print 1 to 5

 <html>
 <body>
 <?php
  $i=1;
  while($i<=5)
  {
  echo $i;
  $i++;
  }
  ?>
 </body>
 </html>

Output

1 2 3 4 5