I've looked at Is it possible to pass parameters by reference using call_user_func_array()?, and http://php.net/manual/en/function.call-user-func-array.php. The approved technique for passing by reference using call_user_func_array() seems to be by making the parameter array an array of variable references. For example, setting $parameters = array( &$some_variable)
. My question is, can we instead make the parameter array an array of variables (not references), and pass the whole parameter array as a reference instead? This is illustrated below:
function toBeCalled( &$parameter1, $parameter2 ) {
//...Do Something...
}
$changingVar = 'passThis';
$changingVar2 = 'passThisToo';
$parameters = array( $changingVar, $changingVar2 );
call_user_func_array( 'toBeCalled', &$parameters );
Notice that the function toBeCalled expects the first variable as a reference, and the second as a value. The reason I ask is because the syntax here is convenient, and it seems to work (see this PHP 5.3 patch for the DruTex module for Drupal - http://drupal.org/node/730940#comment-4054054), but I'm just checking what experts think about it.