spl_autoload

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

spl_autoload__autoload()函数的默认实现

说明

spl_autoload(string $class, ?string $file_extensions = null): void

本函数用于 __autoload() 的默认实现。如果未指定任何参数调用 spl_autoload_register(),则此函数在 __autoload() 调用时会自动使用此函数。

参数

class

已实例化的类(和命名空间)的名字。

file_extensions

在默认情况下,本函数先将类名转换成小写,再在小写的类名后加上 .inc 或 .php 的扩展名作为文件名,然后在所有的包含路径(include paths)中检查是否存在该文件。

返回值

没有返回值。

错误/异常

当未找到类或者没有注册其它自动加载器时抛出 LogicException

更新日志

版本 说明
8.0.0 file_extensions 现在允许为 null。

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top