gpt4 book ai didi

php - 调用时间传递引用已被删除

转载 作者:IT王子 更新时间:2023-10-28 23:55:42 27 4
gpt4 key购买 nike

Possible Duplicate:
Call-time pass-by-reference has been deprecated

虽然它可能在 Internet 上的某个地方有记录,但我找不到解决我的问题的方法。自 PHP 5.4 更新以来,传递引用已被删除。

现在我的这部分代码有问题,我希望有人能看到我正在尝试用它做什么,这样他们就可以帮助我解决我的引用传递问题。

下面是有问题的代码:

public function trigger_hooks( $command, &$client, $input ) {
if( isset( $this->hooks[$command] ) ) {
foreach( $this->hooks[$command] as $func ) {
PS3socket::debug( 'Triggering Hook \'' . $func . '\' for \'' . $command . '\'' );
$continue = call_user_func( $func, &$this, &$client, $input );
if( $continue === FALSE ) {
break;
}
}
}
}

.

最佳答案

只有 调用时间 传递引用被删除。所以改变:

call_user_func($func, &$this, &$client ...

到这里:

call_user_func($func, $this, $client ...

&$this 在 PHP4 之后应该永远不需要了。

如果您绝对需要通过引用传递 $client,请改为更新函数 ($func) 签名 (function func(&$client) {)

关于php - 调用时间传递引用已被删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12322811/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com