Dynamic class method invocation in PHP

There is more than one way to do that:

$this->{$methodName}($arg1, $arg2, $arg3);
$this->$methodName($arg1, $arg2, $arg3);
call_user_func_array(array($this, $methodName), array($arg1, $arg2, $arg3));

You may even use the reflection api http://php.net/manual/en/class.reflection.php

Leave a Comment