#41214 [Opn->Bgs]: referencing a reference parameter on a function-local variable does not work

From: Date: Fri, 27 Apr 2007 17:11:24 +0000
Subject: #41214 [Opn->Bgs]: referencing a reference parameter on a function-local variable does not work
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112009@lists.php.net to get a copy of this message
ID: 41214 Updated by: tony2001@php.net Reported By: php at warhog dot net -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Linux (Ubuntu 6.10/Linux 2.6.17) PHP Version: 5.2.1 New Comment: You're creating a reference to the variable that exists only in the function scope. Previous Comments: ------------------------------------------------------------------------ [2007-04-27 17:04:28] php at warhog dot net Description: ------------ When having a reference-variable as parameter in a function and referencing it on a local variable (inside the function) the variable will keep the referenced value inside the function but not outside. That's not the way I understand references in PHP. Reproduce code: --------------- <?php function yet_another_function(&$foo) { $_foo = 3; $foo =& $_foo; var_dump($foo); } yet_another_function($bar); var_dump($bar); ?> Expected result: ---------------- int(3) int(3) Actual result: -------------- int(3) NULL ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41214&edit=1

« previous php.bugs (#112009) next »