#46277 [Opn->Bgs]: implicit reference is not safe to use

From: Date: Mon, 06 Apr 2009 21:18:49 +0000
Subject: #46277 [Opn->Bgs]: implicit reference is not safe to use
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135606@lists.php.net to get a copy of this message
ID: 46277 Updated by: jani@php.net Reported By: ido at niger dot co dot il -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: * PHP Version: 5CVS, 6CVS (2008-10-22) New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php http://www.php.net/manual/en/language.references.whatdo.php Previous Comments: ------------------------------------------------------------------------ [2008-10-12 10:26:04] ido at niger dot co dot il Description: ------------ The example prints 9 as the value of $a , though it should be 8; The fact the referencing $a[0] causes $a[0] to become a reference itself , is dangerous in cases like this where it is possible to change the value of $a[0] though it was not originally defined as a reference. Reproduce code: --------------- function a($c){ $c[0] = 9; } $a[0] = 8; $c = &$a[0]; a($a); echo $a[0]; Expected result: ---------------- The value of $a should be 8 Actual result: -------------- The value printed is 9 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46277&edit=1

« previous php.bugs (#135606) next »