#50748 [Opn->Bgs]: func_get_args() should be able to pass variables as reference

From: Date: Thu, 14 Jan 2010 11:16:51 +0000
Subject: #50748 [Opn->Bgs]: func_get_args() should be able to pass variables as reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-146642@lists.php.net to get a copy of this message
ID: 50748 Updated by: johannes@php.net Reported By: gahgneh+php at gmail dot com -Status: Open +Status: Bogus Bug Type: Variables related Operating System: Windows XP SP3 PHP Version: 5.2.12 New Comment: For passing references we would need to know at the time the parameters are prepared, before actually invoking the function, that references are expected. That can only be done by defining it in the signature ... but when doing that func_get_args() is rather useless - the only case would be an undefined number of reference parameters which can be simulated by using an array of references as parameter ... but then again: There's barely any reason for using references these days in PHP. Previous Comments: ------------------------------------------------------------------------ [2010-01-14 11:00:04] gahgneh+php at gmail dot com Description: ------------ func_get_args() should be able to pass variables as reference Reproduce code: --------------- function ref(){ $args = func_get_args(); $args[0] = 10; $args[1] = 11; } $value = 0; $value2 = 1; ref($value, $value2); echo $value,$value2; // prints 01 Expected result: ---------------- $value to contain "int 10" and $value2 to contain "int 11" There should be a * pointer operator like C++, to tell the variable to behave like function ref(int* p = null){ *p = 10; } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=50748&edit=1

« previous php.bugs (#146642) next »