I pass the data to the Index method, but how to pass if the method is call like that ?
if (method_exists($controller, $method)) {
$controller->{$method}($controller);
} else {
$controller->Index('test');
}
I pass the data to the Index method, but how to pass if the method is call like that ?
if (method_exists($controller, $method)) {
$controller->{$method}($controller);
} else {
$controller->Index('test');
}
You can use call_user_func_array()
instead.
Example:
call_user_func_array(array($obj, 'some_func'), array('a', 'b'));
The above code will call a method named some_func
from the object $obj
with 2 parameters 'a'
and 'b'