Checking If a Class Exists in PHP


Use class_exists() to check if a class has been defined.

Source Code

if (class_exists('MyClass')) {
    echo "MyClass exists.";
} else {
    echo "MyClass does not exist.";
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments