On Wed, Oct 7, 2009 at 3:42 PM, tedd <tedd.sperl...@gmail.com> wrote:

> However, what I find wacky about all of this is:
>
>  for($i=1; $i<=10; $i++)
>    {
>    echo($i);
>    }
>
> and
>
>   for($i=1; $i<=10; ++$i)
>    {
>    echo($i);
>    }
>
> Do exactly the same thing. I would have expected the first to print 1-10,
> while the second to print 2-10, but they both print 1-10.
>
> Cheers,
>
> tedd
>
>
Not wacky at all. Think of them both this way:

<?php
$i = 1;
while ($i <= 10) {
    $i++;
    echo ($i);
}

// or

$i = 1;
while ($i <= 10) {
    ++$i;
    echo ($i);
}

?>

Andrew

Reply via email to