spl_autoload
Function • Params and return types changed in PHP 8.0
Default implementation for __autoload().
spl_autoload Function synopsis
spl_autoload(string $class, ?string $file_extensions = null): void
Parameters
$class
Typestring
The name of the class being instantiated.
When calling the function, the name of the class with the namespace is passed to the parameter.
The $class will not contain the leading backslash of a fully-qualified identifier.
$file_extensions
OptionalType?stringDefault valuenull
By default it checks all include_pathsto
contain filenames built up by the lowercase class name appended by the
filename extensions .inc and .php.
Return value
The spl_autoload function is a void function; it does not return any values.
Changes to the spl_autoload Function
PHP 8.0
- Return type added:
void - Parameter name of parameter #1 changed:
$class_nameto$class - Parameter type added for parameter #1 (
$class):string - Parameter type added for parameter #2 (
$file_extensions):?string - Parameter default value added for position #2 (
$file_extensions):null
- spl_autoload($class_name, $file_extensions)
+ spl_autoload(string $class, ?string $file_extensions = null): void spl_autoload Function Availability
spl_autoload Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |