|  | Posted by Rik on 07/30/07 21:51 
Or it could have something to with operator precedence:
 http://nl3.php.net/manual/en/language.operators.php#language.operators.p=
 recedence
 In short terms, this is indeed a bug, and it seems they fucked it up:
 
 <?php
 $k =3D 1;
 $a =3D array();
 $a[$k] =3D $k++;
 var_dump($a,$k);
 ?>
 array(1) {
 [2]=3D>
 int(1)
 }
 int(2)
 
 '[' _should_ be evaluated BEFORE ++ / -- according to the manual.....
 
 Evaluting should be, according to precedence:
 
 1. $a[$k] =3D $k++;
 2. $a[1] =3D 1; $k =3D $k + 1;
 3. $a[1] =3D 1; $k set to 2;
 4. $a[1] set to 1, $k set to 2;
 
 Evaluating as it is done:
 1. $a[$k] =3D $k++;
 2. $a[$k] =3D 1; $k =3D $k + 1;
 3. $a[$k] =3D 1; $k is set to 2;
 4. $a[2] is set to 1, $k is set to 2;
 
 
 (damn, it's hard to write '=3D' as an 'operator yet to handle' instead o=
 f an  =
 
 intermediate 'this is what the vars are now)
 
 If this is really a bug, I'm very curious how they would solve it... It =
 so  =
 
 basic a lot can go wrong in peoples code...
 -- =
 
 Rik Wasmus
 [Back to original message] |