php中的自动加载功能

sre*_*ith 4 php function

是否可以自动加载功能?

我所拥有的是我编写的函数分布在以函数名称命名的不同文件上,因此我需要的是自动加载包含该函数的文件.有没有办法做到这一点?

Pio*_*otr 5

您可以自动加载类,因此如果您将函数设置为类的静态方法,那么它将起作用.

abstract class Util
{
    static function doSomething() {

    }
}
Run Code Online (Sandbox Code Playgroud)

用法:

Util::doSomething();
Run Code Online (Sandbox Code Playgroud)