justclint
3/7/2016 - 7:46 PM

php check methods

// invoke method
$object = getObject();
$method = 'methodName';
echo $object->$method();
// or
$returnValue = call_user_func( array( $object, $method ) ); 

// get all methods of a class
print_r( get_class_methods( 'ClassName' ) );

// check if a specific method exists in class
if ( in_array( $method, get_class_methods( $object ) 
{
	echo $object->$method();  
}
// or
if ( method_exists( $object, $method ) ) {
	echo $object->$method();  
}

// check if a method is callable
if ( is_callable( array( $object, $method ) ) ) 
{
	echo $object->$method();	
}