English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP tutorial

Advanced PHP tutorial

PHP & MySQL

PHP reference manual

PHP method_exists() function usage and example

PHP Class/Object function reference manual

The method_exists() function checks if the class method exists

Syntax

method_exists($object, $method_name);

Definition and usage

It checks if the class method exists in the given object.

Parameter

Serial numberParameters and descriptions
1

object(Required)

Object to be tested

2

mthod_name(Required)

Method name.

Return value

If the method with the given method_name is defined for the given object, it returns TRUE, otherwise it returns FALSE.

Online examples

The following is the usage of this function-

<?php
   $directory = new Directory('.');
   var_dump(method_exists($directory,'anything'));
?>
Test to see‹/›

It will produce the following result-

bool(false)

  PHP Class/Object function reference manual