It seems like the following from the PHP manual regarding for
loops is incorrect.
They behave like their C counterparts.
This is my understanding of for
loops.
In Cfor (i = foo; i < 10; i++) { /* body */ }
is equivalent to
if ( i = foo )
{ while (i < 10)
{ /* body */
i++;
}
}
In PHP the comparable loopfor ($i = $foo; $i < 10; $i++) { /* body */ }
becomes
$i = $foo;
while ($i < 10)
{ /* body */
$i++;
}
The difference is that in PHP $i = $foo
is not a condition but rather a convenient place for a statement. Suppose we change the single =
to ==
. The distinction becomes significant. Is this correct? If so, then PHP and C loops behave differently and the manual is incorrect, right?