PHP中的“&”是什么意思?

前端之家收集整理的这篇文章主要介绍了PHP中的“&”是什么意思?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
考虑这个 PHP代码: @H_502_1@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:

@H_502_1@<?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相关文章