Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

method_exists

Description

The method_exists of Class / Object for PHP checks if the class method exists.

Syntax

method_exists ( mixed $object , string $method_name ) : bool

Parameters

object

An object instance or a class name

method_name

The method name

Return

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

Examples

1

<?

class myclass
{
    function myfunction()
    {
    }
}

$object = new myclass();
$method_name = "myfunction";

$return = method_exists($object, $method_name);

var_export($return);

?>
true

2

<?

class myclass
{
    function myfunction()
    {
    }
}

$object = "myclass";
$method_name = "myfunction";

$return = method_exists($object, $method_name);

var_export($return);

?>
true
HomeMenu