Re: Whacky increment/assignment logic with $foo++ vs ++$foo

From: Date: Tue, 06 Oct 2009 18:11:31 +0000
Subject: Re: Whacky increment/assignment logic with $foo++ vs ++$foo
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.general 
Request: Send a blank email to php-general+get-298677@lists.php.net to get a copy of this message
----- Original Message ---- > From: tedd <tedd.sperling@gmail.com> > To: Martin Scotta <martinscotta@gmail.com>; Paul M Foster <paulf@quillandmouse.com> > Cc: php-general@lists.php.net > Sent: Tue, October 6, 2009 11:08:14 AM > Subject: Re: [PHP] Whacky increment/assignment logic with $foo++ vs ++$foo > > At 10:48 AM -0300 10/6/09, Martin Scotta wrote: > > No matter how silly it can looks like (a = a++) it is still completely valid > > code and it SHOULD run without problems. > > Yeah, it's a valid as: > > $a = $a; > > and does the same thing, which is nothing. > > If you want a statement that does something, then use: > > $a = ++$a; > > or simply: > > $a++; > > or > > ++$a; > > Any of those will increment $a, whereas ($a = $a++;) does nothing. > > Cheers, > > tedd > > -- ------- > http://sperling.com > http://ancientstones.com > http://earthstones.com > > -- PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php I find it interesting for a discussion to go on this long for something as $a = $a++; which should have never happened in the first place ;) Regards, Tommy

« previous php.general (#298677) next »