Re: ++ BUG??

From: Date: Mon, 27 Nov 2000 10:18:26 +0000
Subject: Re: ++ BUG??
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-27326@lists.php.net to get a copy of this message
On Sun, 26 Nov 2000, Marcin Orlowski wrote: > Hi, > > This: > > $idx=0; > [loop] > { > $idx = ($idx++)%2; > echo $idx; > } > > does not work as expected (idx is always 0). But this: > > $idx = ($idx+1)%2; > > will do act correctly. Known bug (PHP4.0.3/debian)? Hi! $i= ($i++)%2; is processed as follows: 1) evaluate right-hand expression 2) increment $i 3) assign result of expression to $i so, let's say $i == 0 1) expression evalutated to 0 2) $i incremented to 1 3) result (0) assigned to $i => $i=0 No bug there! Cheers, Marco

« previous php.general (#27326) next »