How does the __autoload() function in PHP help in managing class dependencies and includes?

When working with classes in PHP, managing class dependencies and includes can become cumbersome as the project grows. The __autoload() function in PHP helps in managing class dependencies and includes by automatically loading the class files when they are needed, based on the class name. This eliminates the need to manually include each class file, making the code more organized and easier to maintain.

// Autoload function to automatically include class files
function __autoload($class_name) {
    include $class_name . '.php';
}

// Example usage of autoload function
$obj = new MyClass();