Answer the question
In order to leave comments, you need to log in
How to get (use) an array of parameters call_user_func_array?
Anyway, back to one question..
In the index.php entry point, I run the application class... $app=new App();
in the App class in the constructor
public function __construct (){
...
call_user_func_array([$this->controller,$this->method],$this->params);
}
public function lal($param1=NULL,$param2) {
echo $param1; //foo
echo $param2; //bar
}
Answer the question
In order to leave comments, you need to log in
https://wiki.php.net/rfc/argument_unpacking
n PHP 5.6 and later, argument lists may include the ... token to denote that the function
accepts a variable number of arguments. The arguments will be passed into the given variable as an array; for example:
Example #13 Using ... to access variable arguments
<?php
function sum(...$numbers) {
$acc = 0;
foreach ($numbers as $n) {
$acc += $n;
}
return $acc;
}
echo sum(1, 2, 3, 4);
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question