method_exists

Checks if the class method exists

&reftitle.description; `bool` `method_exists` ``object``string```object_or_class` `string` `method`

Checks if the class method exists in the given `object_or_class`.

&reftitle.parameters;

`object_or_class`

- An object instance or a class name

`method`

- The method name

&reftitle.returnvalues;

Returns &true; if the method given by `method` has been defined for the given `object_or_class`, &false; otherwise.

&reftitle.changelog;

&Version; | &Description;
7.4.0 | Class checks against inherited private methods now return `false`.

&reftitle.examples;

### `method_exists` example

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

&example.outputs;

    bool(true)

### Static `method_exists` example

    <?php
    var_dump(method_exists('Directory','read'));
    ?>

&example.outputs;

    bool(true)

&reftitle.notes; ¬e.uses-autoload;

The `method_exists` function cannot detect methods that are magically accessible using the `__call` magic method.

&reftitle.seealso;

- `function_exists`
- `is_callable`
- `class_exists`