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?
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();
Use:
include("path");
or
require_once("path");
References:
http://php.net/manual/en/function.include.php
http://php.net/manual/en/function.require-once.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With