|
Posted by Toby Inkster on 01/04/07 15:10
bill wrote:
> Shouldn't there be a bracket after the while statement ?
Not needed.
while (x) y;
is equivalent to:
while (x)
{
y;
}
You only need to use curly brackets after while() if you want to iterate
over more than one line, like this:
while (x)
{
y;
z;
}
The same is true of if(), elseif(), else, for(), foreach() and probably
others that I'm forgetting.
For example:
<?php
$countTo99 = rand(0,1);
if ($countTo99)
for ($i=0;$i<10;$i++)
for ($j=0;$j<10;$j++)
print "{$i}{$j}\n";
else
print "I decided not to count.\n";
?>
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|