Difference between class_exists(),method_exists() and is_callable() function.

Started by sams.raghu, Jul 10, 2008, 08:15 PM

Previous topic - Next topic

sams.raghu

class_exists(),method_exists() and is_callable() function in PHP


The class_exists() function accepts a class name and checks the list of declared
classes to see if it exists, while the method_exists() function accepts an object
instance and a method name, and checks the instance to see if it contains a matching
method.

You can also use the is_callable() function to test for the existence of a class
method using the class name.

For checking  the existence of a method within a class from within the class
definition itself, use the $this construct in combination with either method_
exists() or is_callable().