Why does the error “expected to be a reference, value given” appear?

后端 未结 5 1258
天命终不由人
天命终不由人 2021-01-17 07:06

It fires out when I try to call function with argument by reference

function test(&$a) ...

through

call_user_func(\'tes         


        
5条回答
  •  有刺的猬
    2021-01-17 07:49

    From the manual for call_user_func()

    Note that the parameters for call_user_func() are not passed by reference.

    So yea, there is your answer. However, there is a way around it, again reading through the manual

    call_user_func_array('test', array(&$b));
    

    Should be able to pass it by reference.

提交回复
热议问题