How to handle 'fatal error: class not found in php'?

Example:

$obj = new UndefinedClass();

Attempting to instantiate a class that hasn't been defined or included.

Solution:

Ensure the class is properly defined in your code or is included from external sources. Using an autoloader can also help.


include 'path_to_UndefinedClass.php';
$obj = new UndefinedClass();

Beginner's Guide to PHP