What is the difference between directly including classes with require and using __autoload in PHP?

When directly including classes with require, you need to manually include each class file in your code, which can become tedious as your project grows. On the other hand, using __autoload in PHP allows you to define a function that automatically includes the class file when it is needed, saving you from having to manually include each class file.

// Using __autoload to automatically include class files when needed
function __autoload($class) {
    require_once $class . '.php';
}

// Now you can simply use classes without manually including their files
$obj = new MyClass();