Is the a way in php to create a function which executes provided function (as an arguments) with provided argument (of the provided function - as an array).
Here is some code:
class Worker
{
public function execute($func, $paramsArr)
{
php_func_executer($func, $paramsArr); //the function that I would like to have
}
}
in other php file I will do as follow:
Class SomeClass
{
public function test($varA, $varB)
{
//do something
}
public function exeText()
{
...
$worker = new Worker();
$worker->execute(test, [$varA, $varB]);
}
}
I know about call_user_func_array but here I don't want to pass the name of the function (as string), I want to pass the function itself (as seen in the code above)
Thanks!
call_user_func_arrayis any callable, so you can pass a function to it, not name only.