filed passing by reference using call_user_func()
| From: | KUBO Atsuhiro | Date: | Tue, 30 Jul 2002 04:05:17 +0000 |
| Subject: | filed passing by reference using call_user_func() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-86321@lists.php.net to get a copy of this message | ||
Hi, all.
I found problem of call_user_func() with passing by reference.
In test code, I expect that $test1 and $test2 and $test3 are
overwritten by MyFunction. However, $test2 is not overwritten.
Is this right behavior?
following test code:
<?php
$test1 = 'NG';
MyFunction($test2);
$test2 = 'NG';
call_user_func('MyFunction', $test2);
$test3 = 'NG';
call_user_func('MyFunction', &$test3);
print '$test1 is ' . $test1 . "\n";
print '$test2 is ' . $test2 . "\n";
print '$test3 is ' . $test3 . "\n";
exit();
function MyFunction(&$arg) {
$arg = 'OK';
}
?>
--
KUBO Atsuhiro e-mail: kubo@isite.co.jp