#46649 [Opn->Csd]: Setting array element with that same array produces inconsistent results

From: Date: Sun, 23 Nov 2008 20:39:54 +0000
Subject: #46649 [Opn->Csd]: Setting array element with that same array produces inconsistent results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-131232@lists.php.net to get a copy of this message
ID: 46649 Updated by: lbarnaud@php.net Reported By: binarysurgeon at gmail dot com -Status: Open +Status: Closed Bug Type: *General Issues Operating System: Linux 2.6 PHP Version: 5.2.6 New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2008-11-22 23:08:36] binarysurgeon at gmail dot com Description: ------------ When setting an a particular array element to the array itself, results are different when it's inside a function vs outside the function. Reproduce code: --------------- function func() { $a[1] = '1'; $a[0] = $a; var_dump($a); } func(); $a[1] = '1'; $a[0] = $a; var_dump($a); Expected result: ---------------- I'm not sure what to expect but at the vary least, the results should be consistent. Results were consistent in 5.2.1. array(2) { [1]=> string(1) "1" [0]=> array(1) { [1]=> string(1) "1" } } array(2) { [1]=> string(1) "1" [0]=> array(1) { [1]=> string(1) "1" } } Actual result: -------------- array(2) { [1]=> string(1) "1" [0]=> NULL } array(2) { [1]=> string(1) "1" [0]=> array(1) { [1]=> string(1) "1" } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46649&edit=1

« previous php.bugs (#131232) next »