How can the spl_autoload_register() function be effectively utilized to replace the deprecated __autoload() function in PHP?

The spl_autoload_register() function can be effectively utilized to replace the deprecated __autoload() function in PHP by registering a custom autoloader function or a class method. This allows for more flexibility and control over the autoloading process, as multiple autoload functions can be registered and executed in a specific order.

// Register a custom autoloader function
spl_autoload_register(function($class) {
    include 'classes/' . $class . '.php';
});

// Register a class method as an autoloader
spl_autoload_register('MyClass::autoload');