考虑这段 PHP 代码:
call_user_func(array(&$this, 'method_name'), $args);
我知道它在定义函数时意味着按引用传递,但在调用函数时是吗?
最佳答案
来自Passing By Reference文档页面:
You can pass a variable by reference to a function so the function can modify the variable. The syntax is as follows:
<?php
function foo(&$var)
{
$var++;
}
$a=5;
foo($a);
// $a is 6 here
?>
...In recent versions of PHP you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);
关于php - "&"在 PHP 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1006652/