RE: [PHP] Increment

From: Date: Thu, 29 Jun 2000 21:58:10 +0000
Subject: RE: [PHP] Increment
Groups: php.general 
Request: Send a blank email to php-general+get-3911@lists.php.net to get a copy of this message
Yup, I goofed. had : while{ $i=1; if{ } } echo $i; change it to: $i=1; while{ if{ } } echo $i; And it works. 10 hours of coding made me blind. Thanks again, Peter -----Original Message----- From: Robert V. Zwink [mailto:rzwink@microcenter.com] Sent: Thursday, June 29, 2000 5:56 PM To: Peter Benoit; 'Robert V. Zwink'; PHP-General Subject: Re: [PHP] Increment is your loop inside of a function that doesn't have $i defined as Global? -Rob Z. ----- Original Message ----- From: "Peter Benoit" <pbenoit@triton-network.com> To: "'Robert V. Zwink'" <rzwink@microcenter.com>; "PHP-General" <php-general@lists.php.net> Sent: Thursday, June 29, 2000 5:51 PM Subject: RE: [PHP] Increment > Late in the day, typed it fast in the email. > > $i increments within the loop (returns 13 when doing echo $i;), but outside > the loop I still get 1. Wierd. > > -----Original Message----- > From: Robert V. Zwink [mailto:rzwink@microcenter.com] > Sent: Thursday, June 29, 2000 5:50 PM > To: Peter Benoit; PHP-General > Subject: Re: [PHP] Increment > > > You are check the value to "blue", should be checking the value of "$blue" > > In your example, the if statement will never evaluate true, and $i will > never increment. > > Either > > $i++ > or > ++$i > > try something like: > <? > $i =1; > echo $i++; > > $i=1; > echo ++$i; > ?> > > Both are correct it just depends on when you want to check the value. > > -Rob Z. > > ----- Original Message ----- > From: "Peter Benoit" <pbenoit@triton-network.com> > To: "PHP-General" <php-general@lists.php.net> > Sent: Thursday, June 29, 2000 5:34 PM > Subject: [PHP] Increment > > > > $i = 1; > > > > for(whatever){ > > $i++; > > } > > > > echo $i > > > > I want $i to increment, how is this done correctly in PHP? > > > > TIA, > > Peter > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#3911) next »