RE: [PHP] For Loops !
| From: | Benton Jackson | Date: | Mon, 31 Jul 2000 21:49:57 +0000 |
| Subject: | RE: [PHP] For Loops ! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9292@lists.php.net to get a copy of this message | ||
> From: Matt McClanahan [mailto:cardinal@dodds.net]
>
> On Mon, 31 Jul 2000, TomHenry wrote:
>
> > I think of it this way
> >
> > for ($var=0;$var<10;$var++) { //some code stuff here }
> >
> > is shorthand for
> >
> > $var=0;
> > if($var<10){
> >
> > //some code stuff here
> >
> > $var++;
> > }
>
> The two are not the same. The for loop will first set $var to 0 and
> repeat, incrementing $var by 1, until $var < 10. The if check will set
> $var to 0, run the code if 0 < 10, increment $var by 1, and finish.
I think he meant "while" instead of "if". Then it's the same.