CopyPastehas never been so tasty!

While loop in php

by anonymous

  • 0
  • 0
  • 0

this simple article you will learn that how we can use while loop in php.

While loop:

While loop is a control statement. While loop run the code when specified condition is true. The code repeats its iteration until the condition become false.


while (variable<end value)
code to be executed

While loop in PHP:

While loop is an iterative statement that is executed on a specified condition. In the given code we have intialized a variable counter with 1 and in while block we set a condition counter is less than and equal to 12. This loop start executing because counter value is on at the start which is less then 12 and increment the counter variable by one when the counter variable reached the value 13 while loop terminate because condition became false.


$counter = 1;
while ( $counter <= 12 ) {
print "$counter times 2 is ".($counter*2)."<br>";

Above is a simple code of while loop in php.

This simple article tells that how we can use while loop in php.

Add A Comment: