do..while Loop in PHP


Prev Tutorial Next Tutorial

do..while Loop in PHP

do..while loop is used where you need to execute code at least once. The do...while loop will always execute the block of code once, it will then check the condition, and repeat the loop while the specified condition is true.

Syntax

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

Example of do....while Loop in PHP

<?php

$x = 0; 

do
{
    echo "$x <br>";
    $x++;
} while ($x <= 10);

?>

Output

0 1 2 3 4 5 6 7 8 9 10

Prev Tutorial Next Tutorial

Advertisements
Download Projects