$dollars = 15;
while ($dollars > 10)
{
echo "Hey, doll, I'm loaded with cash!";
echo "I have ".$dollars." dollars.<br>";
$dollars=$dollars-1;
}
The above code, like an if statement, evaluates the condition. If the condition evaluates as true, the process code will run. Unlike an if statement, the process code will keep looping until the condition evaluates as false.
Also notice that the condition is tested first and then the process code is run (if true). This is differerent than the Do While Loop.
Here's another example:whileloops.php
|