|
A Do While loops is similar to a While loop, however, a Do While loop always goes through the process code at least once. This is because the condition is tested after the process code. The process code will loop if the end condition is true.
Here's some code:
$dollars = 150;
Do
{
echo "Hey, doll, I'm loaded with cash!";
echo "I have ".$dollars." dollars.<br>";
$dollars=$dollars-1;
}
while ($dollars > 0) ;
The above code evaluates the condition at the end. If the condition evaluates as true, the process code will loop.
Here's another example:dowhileloops.php
|