while (expression)
statement
If the expression evaluates to
true, the statement is
executed and then the expression is
reevaluated (if it is true, the body of the loop
is executed, and so on). The loop exits when the
expression evaluates to
false.
As an example, here's some code that adds the whole
numbers from 1 to 10:
$total = 0;
$i = 1;
while ($i <= 10) {
$total += $i;
}
The alternative syntax for while has this
structure:
while (expr):
statement;
...;
endwhile;
For example:
$total = 0;
$i = 1;
while ($i <= 10):
$total += $i;
endwhile;