加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 13:58:19 所属栏目:PHP教程 来源:网络整理
导读:考虑这个 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 modif
考虑这个 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);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读