PHP Example HTML Javascript jQuery Ajax CSS Java MORE

PHP do-while loops

The do...while loop will always execute the block of code once In PHP do..while loop is similar to while loop but one key difference between them.The do...while loop will always execute the block of code once. If the the condition is true then code of block executed repeatedly, until the condition becomes false.

But in while loops execute a block of code while the specified condition is true.

Syntax

do {
    code to be executed;
} while (condition is true);
<?php
$a=1;
do
{
echo $a;
$a++;
}
while($a<=10)
?>

Run It Yourself »