can a function variable be assigned to a class variable at runtime? a kind of "function pointer" like C
something like this: (this will not work, because the amount goes beyond A, but this is the pattern that I have in mind)
class A {
public $function_name;
public functon run($arg1,$arg2){
$function_name($arg1,$arg2);
}
}
function sum($a,$b){
echo $a+$b;
}
$a=new A();
$a->function_name='sum';
$a->run();
[edit] I know that there is a "call_user_func", but this is necessary because I understand that I have a function in the scope or using the open class method.
source
share