Bug #17309 Updated: pass by reference in call_user_func
| From: | bram at totalgsm dot net | Date: | Fri, 05 Jul 2002 15:34:57 +0000 |
| Subject: | Bug #17309 Updated: pass by reference in call_user_func | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13230@lists.php.net to get a copy of this message | ||
ID: 17309
Updated by: bram@totalgsm.net
Reported By: pmoor@netpeople.ch
Status: Open
Bug Type: Variables related
Operating System: linux
PHP Version: 4.2.1
New Comment:
This might be a duplicate of:
http://bugs.php.net/bug.php?id=17246
However, this test case is clearer.
Previous Comments:
------------------------------------------------------------------------
[2002-07-05 11:34:10] bram@totalgsm.net
This might be a duplicate of:
http://bugs.php.net/bug.php?id=17246
However, this test case is clearer.
------------------------------------------------------------------------
[2002-07-05 11:32:05] bram@totalgsm.net
A workaround might be using variable function name like
$func_name = 'pass_by_reference';
$funcname($data);
However this doesn't work if the $func_name is an array to call a user
method (which is a flaw in PHP :( )
------------------------------------------------------------------------
[2002-05-20 11:01:03] pmoor@netpeople.ch
i've disabled the "call-time pass-by-reference" option in my
configuration file.
now, when trying to call_user_func a function with
reference-parameters, it won't work, unless i
call-time-pass-by-reference my parameters despite the warning.
( this bug might be related to bug #17246 )
here a small example:
function pass_by_reference( &$param ) {
$param[] = "another entry";
}
$data = array( "a first entry" );
call_user_func( "pass_by_reference", $data );
var_dump($data); // $data contains only one element ( "a first entry" )
( == unexpected behaviour )
$data = array( "a first entry" );
call_user_func( "pass_by_reference", &$data ); // Warning: Call-time
pass-by-reference has been deprecated - argument passed by value; ...
var_dump($data); // $data contains both elements ( "a first entry",
"another entry" ) ( == expected behaviour )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17309&edit=1