PHP do Keyword
Example
Create a loop that always runs at least once:
<?php
$i = 5;
do {
echo $i;
echo "<br>";
$i--;
} while($i > 6);
?>
Try it Yourself »
Definition and Usage
The do
keyword creates a loop which always runs at least once. It is used together with
the while
keyword to create a do...while
loop.
Related Pages
The while
keyword.
Read more about do...while loops in our PHP do while Loop Tutorial.
❮ PHP Keywords
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.