PHP Functions - Class Exists and Method Exists
One of the most useful php function is class_exists. It allows you to check if a certain class already exists and then take action accordingly (such as including a file with the class definition, calling an existing function etc). This is important since many of us use functions from plugins in our themes and you don’t want to get a fatal error when the plugin gets deactivated!
The php function class_exists accepts two arguments: the class name which needs to be checked and a flag that indicates whether the function should also call __autoload(). If you don’t set the flag to false, then class_exists will automatically call __autoload() for you when checking to see if the class exists. This is a useful feature if you are using autoloaders for your classes and helps to avoid having to do extra work with these kinds of checks.
Another related php function is method_exists which allows you to check if a class methods exist in the given object. The function is very similar to is_callable except it also checks if the methods are private or static.
The only difference between the two functions is that is_callable requires an instance of the class to check while method_exists does not. Using method_exists with private or static methods can cause issues when using the reflection class built into PHP, as it can return results that don’t match the intended behaviour.