Home » , , » While loops in PHP

While loops in PHP

Written By Unknown on Kamis, 17 Desember 2009 | 09.21

Loops are used to execute the specified block of codes for a number of times, or while the specified condition is true. 


In PHP we have the following looping statements. They are

  1. While loop
  2. Do-While loop
  3. For loop
  4. foreach loop

WHILE loop:

The while loop is used to execute the block of code while the specified condition is true. While loop is a entry controlled loop;

Syntax:
While (condition)
{
  ---//block of codes to be executed if the condition is true.
  ---
}

Example:

$i=1;
while($i<=5)
  {
  echo "The number is " . $i . "
";

  $i++;
  }

Output:

The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger