The method_exists() function checks if the class method exists.
Syntax
method_exists(object, name_of_method)
Parameters
object − The object instance or class name
name_of_method − The method name
Return
The method_exists() function returns TRUE if the method given by method_name has been defined for the given object, FALSE otherwise.
Example
The following is an example −
<?php $directory = new Directory('.'); var_dump(method_exists($directory,'anything')); ?>
Output
bool(false)
Example
<?php var_dump(method_exists('Directory','read')); ?>
Output
bool(true)