note 83685 added to function.call-user-func-array
| From: | dnhuffatacm dot org at osu1 dot php dot net | Date: | Sat, 07 Jun 2008 18:57:16 +0000 |
| Subject: | note 83685 added to function.call-user-func-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140211@lists.php.net to get a copy of this message | ||
It appears that when PHP executes something like:
$a = array(1,2,3);
$b =& $a[1];
both $b and $a[1] are converted into references to a common value -- makes sense until you transfer
that to a call_user_func:
call_user_func_array('foo', $a);
suddenly, inside foo, the second parameter is passed by reference!
And you can't call this wrong, only another subtly of references.
Note it appears that ksort($a) will remove the reference as well as put the elements in key order so
you (probably) get what you expect. (see below on the use of a foreach ($a as &v).)
----
Server IP: 209.41.74.194
Probable Submitter: 76.105.247.92
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func-array.php
Edit -- https://master.php.net/note/edit/83685
Del: integrated -- https://master.php.net/note/delete/83685/integrated
Del: useless -- https://master.php.net/note/delete/83685/useless
Del: bad code -- https://master.php.net/note/delete/83685/bad+code
Del: spam -- https://master.php.net/note/delete/83685/spam
Del: non-english -- https://master.php.net/note/delete/83685/non-english
Del: in docs -- https://master.php.net/note/delete/83685/in+docs
Del: other reasons-- https://master.php.net/note/delete/83685
Reject -- https://master.php.net/note/reject/83685
Search -- https://master.php.net/manage/user-notes.php