RE: [PHP] Increment

From: Date: Thu, 29 Jun 2000 21:51:59 +0000
Subject: RE: [PHP] Increment
Groups: php.general 
Request: Send a blank email to php-general+get-3907@lists.php.net to get a copy of this message
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 >

« previous php.general (#3907) next »