Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Invoke method by using reflection.
- * Require PHP5 (>= 5.3.2)
- * @param $method_name
- * @param $obj - An object that invokes the method.
- * @param mothod_args... Arguments for the method.
- */
- public static function invoke_method($method_name, $obj) {
- $class_name = get_class($obj);
- $class = new ReflectionClass($class_name);
- $method = $class->getMethod($method_name);
- $method->setAccessible(true);
- $mothod_args = func_get_args();
- array_shift($mothod_args);
- array_shift($mothod_args);
- return $method->invokeArgs($obj, $mothod_args);
- }
Add Comment
Please, Sign In to add comment