0

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');
}
tereško
  • 58,060
  • 25
  • 98
  • 150
Ben
  • 1,906
  • 10
  • 31
  • 47

1 Answers1

1

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'

Kemal Fadillah
  • 9,760
  • 3
  • 45
  • 63