Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function method_exists()


previous

Advertisements

Syntax

method_exists ( $object, $method_name );

Definition and Usage

Checks if the class method exists in the given object.

Paramters

ParameterDescription
objectRequired. The tested object
mthod_nameRequired. The method name.

Return Value

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

Example

Following is the usage of this function:

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

It will produce following result:

bool(true)

previous Printer Friendly

Advertisements


  

Advertisements