Reputation: 1029
this is the function:
public function func(&$parameters = array())
{
}
now I need to do this:
$x->func (get_defined_vars());
but that fails. Another way:
$x->func (&get_defined_vars());
it drops an error: Can't use function return value in write context in ...
Then how to do it?
Upvotes: 1
Views: 434
Reputation: 101936
get_defined_vars()
returns an array, not a variable. As you can only pass variables by reference you need to write:
$definedVars = get_defined_vars();
func($definedVars);
Though I don't really see a reason to pass the array by reference here. (If you are doing this for performance, don't do it, as it won't help.)
Upvotes: 6
Reputation: 18064
Try this way:-
call_user_func_array( 'func', $parameters );
See the notes on the call_user_func_array()
function documentation for more information.
Upvotes: 1
Reputation: 3217
public function func(&$parameters = array())
{
}
Not defined correctly.
Upvotes: 3