自动加载功能在PHP中 [英] autoload functions in php

查看:112
本文介绍了自动加载功能在PHP中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能自动加载函数?

Is it possible to autoload functions?

我有写函数分布在以函数名命名的不同文件上,所以我需要自动加载包含该功能的文件自动。
有没有办法做到这一点?

What I have is I have written functions distributed over different files named after the function name, so what I need is to autoload the file containing the function automatically. Is there any way to do this?

推荐答案

您可以 autoload classes ,所以如果你的功能

You can autoload classes, so if you make your functions static methods of classes then it will work.

abstract class Util
{
    static function doSomething() {

    }
}

用法:

Usage:

Util::doSomething();

这篇关于自动加载功能在PHP中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆