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

Advertisements
Download Projects

Advertisements

Download WhatsApp Status Video

Buy This Ad Space Only $50 per Month, Ad Size 300X250 Contact on: [email protected] WhatsApp no. 8882538826

Google Adsense Advertisements