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

From: Date: Sat, 03 Oct 2009 13:57:33 +0000
Subject: Re: Whacky increment/assignment logic with $foo++ vs ++$foo
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-298517@lists.php.net to get a copy of this message
Ben, might be intersting to consider that in ur c axample u r working with a pure memory position, while php works with references. thry it with pointers it I'm pretty shure u get the same result as in PHP. I'm not shure, because I don't work in perl, but doesn't per work on references as well ? ralph_deffke@yahoo.de "Ben Dunlap" <bdunlap@agentintellect.com> wrote in message news:7997e80e0910021458h20ebd75dtfc51f9264f35171b@mail.gmail.com... > mind-blowing. What the heck /is/ supposed to happen when you do this: > > $a = 2; > $a = $a++; > echo $a; > > Seems like any way you slice it the output should be 3. I guess what's ... and, in fact, that /is/ how C behaves. The following code: int a = 2; a = a++; printf("a = [%d]\n", a); Will output "a = [3]". At least on Ubuntu 9 using gcc 4.3.3. So I retract my initial terse reply and apologize for misunderstanding your question. Ben

« previous php.general (#298517) next »