__autoload() is deprecated, use spl_autoload_register() instead¶
Description¶
The initial autoloader was a custom function, that was called whenever a class, interface or trait had to be loaded, but could not be found by PHP yet.
This approach was useful, but limited management operation: in particular, it was not possible to add more functions, or remove some of them. So, it was replaced with the spl_autoload_register()
function, which add a closure to a list of autoloaders.
Example¶
<?php
function __autoload() {}
?>
Solutions¶
Give another name to the
__autoload
function, and register it as autoloader with spl_autoload_register().Remove the
__autoload
function.
In more recent PHP versions, this error message is now __autoload() is no longer supported, use spl_autoload_register() instead.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See autoload.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See autoload.