While Loop
×
Home Courses Community Support
While Loop

When we write the code, some time we require to write the same code many times. For example if we have and array with 10 elements and we want to prinit a message for each element. Then we will have to write the same code 10 times. Loops are the replacement of it. By using loops we don't require the same code again and again.

Php has four type of loops-

  • While Loop
  • Do While Loop
  • For Loop
  • For Each Loop


In this heading we will learn about While Loop and other loops will be explained in next headings of this module.
 

The meaning of while statement is clear from it's name. The code execute untill the condition (while expression) is true.

See below code -

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

Output:

12345

 

enlightenedLikely if statement we can pass group multiple statements with in the same while loop.

 

 

← Preview

Switch Statement

Next →

Do While Loop

NOTES

Our mission is to provide highly effective and quality education via innovative solutions. Geeksdemy look forward to bridge the gap between in-demand technology and academics in order to deliver innovative, easy, interesting and affordable learning across the Globe.

Courses

  • Python
  • Game Development with Unity 3D
  • Arduino
  • PCB & Circuit Designing
  • Robotics and Embedded C
  • 8051/8052 Embedded Systems
  • QuadCopter & UAV
  • MATLAB with Robotics
  • Raspberry Pi
Learn On the Go!
Get the Android App
Get the iOS App