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

call_user_func can only pass parameters by value, not by reference. If you want to pass by reference, you need to call the function directly, or use call_user_func_array, which accepts references (however this may not work in PHP 5.3 and beyond, depending on what part of the manual look at).


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.

Tags:

Php