Is there a significant difference between call_user_func and using variable variables?
Take for example a class such as this:
class someClass{
protected function action_this() { ... }
protected function action_that() { ... }
}
Is this better or more efficient
class myClass extends someClass{
public function doAction($action='this'){
$method="action_{$action}";
if(is_callable (array($this,$method)) ){
call_user_func(array($this,$method));
}
}
}
than
class myClass extends someClass{
public function doAction($action='this'){
$method="action_{$action}";
if(is_callable (array($this,$method)) ){
$this->$method();
}
}
}
Are there conditions under which one might be preferred over the other?
call_user_funcis just the older way -- it was the only way to do it before they added variable functions. Now I would use variable functions.