Reputation: 758
I want to be able to modify a value of a variable that is passed by reference to a function.
<?php
function invoke($what) {
$args = func_get_args();
return call_user_func_array($what, $args);
}
function page(&$page) {
return $page;
}
$page = array();
$page['context'] = 'view';
invoke('page', $page);
?>
When I call invoke(), I'm getting the warning: Parameter 1 to page() expected to be a reference, value given in invoke()
Please what am I doing wrong?
Thanks
Upvotes: 1
Views: 184
Reputation: 57322
you are passing two value in function invoke() and getting only one use the function lke function invoke($what,$second)
or just pass only one like invoke($page);
Upvotes: 2