While Loop in PHP


Prev Tutorial Next Tutorial

While Loop in PHP

The while loop is used when you don't know how many times the script should run. while loops execute a block of code while the specified condition is true same like for loop.

Syntax

while(condition)
{  
//code to be executed  
}  

Example of while Loop in PHP

<?php

$n=0;  
while($n<=10)
{  
echo "$n<br/>";  
$n++;  
}  

?>

Output

0 1 2 3 4 5 6 7 8 9 10

Prev Tutorial Next Tutorial

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements