php - "&"在 PHP 中是什么意思?

标签 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 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/

相关文章:

php - 在重定向到 Yii 中的登录页面时出现软 404 错误

php - 从多个表中比较并插入?

php - 根据产品类别替换 WooCommerce 占位符图像

php - 如何将大数组与数据库进行比较(使用 PHP 或 SQL)

php - 如何使用php和mysql创建视频上传和播放文件

php - 无法使搜索栏响应

php - 如何确定连接到 LDAP (PHP) 的 tls/ssl 安全协议(protocol)版本?

stdin - 如何在新输入之前清除 php STDIN?

php - 在 PHP 中将整数转换为字符串

php - Codeigniter CSRF 保护 VS 选项卡