Re: ++ BUG??

From: Date: Sun, 26 Nov 2000 03:52:36 +0000
Subject: Re: ++ BUG??
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-27222@lists.php.net to get a copy of this message
On Sat, Nov 25, 2000 at 09:50:17PM -0600, Jason wrote: > > > whether there's a bug there or not, it's ambiguous code. You're doing > > > two > > > assignments to $idx on the same line. $idx+1 and $idx++ are NOT equivalent. > > > $idx = ($idx+1)%2 is better code and you don't have to worry about the bug. > > > > > > > Now, normally I don't argue in a public forum, but the PHP manual does say > > "C-style pre- and post-increment and decrement operators". IIRC, C would > > assign to the variable and then increment it. There should be no > > ambiguity. Please correct me if I'm wrong. > > yes, foo($i++) should do foo($i) and then do $i = $i + 1. > However, foo($i+1) should do foo($i+1) and increment $i. oops, typo. that should say "do foo($i+1) and NOT increment $i"

« previous php.general (#27222) next »