spl_autoload_extensions()
spl_autoload_extensions() — Register and return default file extensions for spl_autoload.
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.1.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
This function can modify and check the file extensions that the built in __autoload() fallback function spl_autoload() will be using.
Signature
spl_autoload_extensions(?string $file_extensions = null): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $file_extensions | ?string | If null, it simply returns the current list of extensions each separated by comma. To modify the list of file extensions, simply invoke the functions with the new list of file extensions to use in a single string with each extensions separated by comma. |
Return value
A comma delimited list of default file extensions for spl_autoload().
Example
A runnable snippet:
spl_autoload_extensions(".php,.inc");
Changelog
| Version | Change |
|---|---|
| 8.0.0 | file_extensions is now nullable. |
All PHP 8.5 built-in functions
Reference card built from the PHP manual page spl_autoload_extensions() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.