Home / PHP Tips Generated By ChatGPT / 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."; }