问题描述
虽然可能记录在互联网上的某个地方,我找不到我的问题的解决方案。自从PHP 5.4更新,传递引用已被删除。
While it may be documented somewhere on the internet, I cannot find a solution to my problem. Since the PHP 5.4 update, pass-by-references have been removed.
现在我对这段代码有一个问题,我希望有人能看到我想要做的事情,以便他们可以帮助我
Now I have a problem with this section of code, and I hope somebody can see what I'm trying to do with it so that they can possibly help me with a solution to overcome my pass-by-reference problem.
以下是有问题的代码:
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;
}
}
}
}
。
推荐答案
只有通话时间通过参考被移除。所以改变:
Only call time pass-by-reference is removed. So change:
call_user_func($func, &$this, &$client ...
至此:
call_user_func($func, $this, $client ...
&
&$this
should never be needed after PHP4 anyway period.
如果你绝对需要通过引用传递$ client,更新函数($ func)signature( function func(& $ client){
)
If you absolutely need $client to be passed by reference, update the function ($func) signature instead (function func(&$client) {
)
这篇关于呼叫时间通过引用已删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!