#42152 [Opn->Fbk]: Operator Precedence: postincrement before '['

From: Date: Tue, 31 Jul 2007 11:33:46 +0000
Subject: #42152 [Opn->Fbk]: Operator Precedence: postincrement before '['
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115586@lists.php.net to get a copy of this message
ID: 42152 Updated by: jani@php.net Reported By: php at tfwasmus dot enschedenet dot nl -Status: Open +Status: Feedback Bug Type: Scripting Engine problem Operating System: Windows Xp x64 PHP Version: 5CVS-2007-07-30 (snap) New Comment: Either I missed something but = has lower precedence than [ ? Previous Comments: ------------------------------------------------------------------------ [2007-07-30 23:26:44] php at tfwasmus dot enschedenet dot nl Description: ------------ According to the operator precedence (http://www.php.net/manual/en/language.operators.php#language.operators.precedence), a (post)increment should be evalued after the '['. It seems that isn't true in assigning to an array in PHP5 anymore, while it was in PHP4. Latest snapshots of both checked (30-07-2007). This could also be a documentation problem. Reproduce code: --------------- <?php $k = 1; $a = array(); $a[$k] = $k++; var_dump($a,$k); ?> Expected result: ---------------- array(1) { [1]=> int(1) } int(2) Actual result: -------------- array(1) { [2]=> int(1) } int(2) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42152&edit=1

« previous php.bugs (#115586) next »