method_exists

(PHP 4, PHP 5, PHP 7)
Checks if the class method exists
bool method_exists ( mixed $object, string $method_name )

Checks if the class method exists in the given object.

Parameters:
object

An object instance or a class name

method_name

The method name

Returns:

Returns TRUE if the method given by method_name has been defined for the given object, FALSE otherwise.

Notes:

Using this function will use any registered autoloaders if the class is not already known.

Examples:
method_exists() example
<?php
$directory = new Directory('.');
var_dump(method_exists($directory,'read'));
?>

The above example will output:

bool(true)
Static method_exists() example
<?php
var_dump(method_exists('Directory','read'));
?>

The above example will output:

bool(true)
See also:

function_exists() -

is_callable() -

class_exists() -

doc_php
2016-02-24 16:13:00
Comments
Leave a Comment

Please login to continue.