Answer the question
In order to leave comments, you need to log in
Why autoload classes?
Why autoload classes? Just for convenience or does it save some other resources?
// There is a variant with a function
spl_autoload_register(function ($class) {
include APP. '/' . $class . '.php';
});
$obj = new MyClass();
$obj->myMethod();
Answer the question
In order to leave comments, you need to log in
It provides loading on demand , not these yours.
It's possible, but what for? Always drag everything everywhere. In addition, as long as you have one file in which the includes are made, it’s still all right. But there are projects larger than your site, where there are hundreds and thousands of files . It's very convenient to add another require_once() to a thousand files, right?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question