What role does the __autoload() method play in resolving issues related to object references in PHP?

When working with object references in PHP, it's important to ensure that the necessary classes are loaded before using them. One common issue is encountering "Class not found" errors when trying to instantiate an object that hasn't been included or required in the script. To solve this problem, you can use the __autoload() method to automatically load class files when they are needed, helping to resolve any issues related to object references.

function __autoload($class) {
    include $class . '.php';
}

// Now, when trying to instantiate a class that hasn't been included, __autoload() will be called to load the necessary file.
$obj = new MyClass();