|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-08 08:39 UTC] derick@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 07:00:01 2025 UTC |
Description: ------------ The increment/decrement operators seem to calculate out of order compared to other languages and even previous versions of PHP. I compared this report numerous times against a 4.3.11 install that I am running to verify the inconsistency. In the case of PHP 5.2.x, the increment operator seems to be processed in an inappropriate order to the rest of the statement. In 4.3.11, everything is presented just as expected (as my Expected results display below). Reproduce code: --------------- $a = array(); // Begin Test 1 $b = 0; $a[$b++] = $b; var_dump($a); $a = array(); // Begin Test 2 $b = 0; $a[$b] = $b++; var_dump($a); $a = array(); // Begin Test 3 $b = 10; $a[$b--] = $b; var_dump($a); $a = array(); // Begin Test 4 $b = 10; $a[$b] = $b--; var_dump($a); Expected result: ---------------- array(1){[0] => int(1)} array(1){[0] => int(0)} array(1){[10] => int(9)} array(1){[10] => int(10)} Actual result: -------------- array(1){[0] => int(1)} array(1){[1] => int(0)} array(1){[10] => int(9)} array(1){[9] => int(10)}