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

后端 未结 5 1349
天命终不由人
天命终不由人 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 08:10

    You need to set the variable equal to the result of the function, like so...

    $b = call_user_func('test', $b);
    

    and the function should be written as follows...

    function test($a) {
        ...
        return $a
    }
    

    The other pass by reference work-a-rounds are deprecated.

提交回复
热议问题