Is it possible to pass parameters by reference using call_user_func_array()?

To pass by reference using call_user_func_array(), the parameter in the array must be a reference – it does not depend on the function definition whether or not it is passed by reference. For example, this would work:

function toBeCalled( &$parameter ) {
    //...Do Something...
}

$changingVar="passThis";
$parameters = array( &$changingVar );
call_user_func_array( 'toBeCalled', $parameters );

See the notes on the call_user_func_array() function documentation for more information.

Leave a Comment