Better performance on autoloading php classes
1 may
Autoloading classes is quite useful to avoid including a lot of files during the coding. Moreover you will not have to repeat any include call.
The simplest example is this:
function __autload($name) {
require_once 'lib/'.$name.'.class.php';
}
$glab = new GraficLab();
It will include ‘lib/GraficLab.class.php’ file.
The thing is, each time you call class_exists() function, if the class does not exists, it calls __autload() function. If autloading handler is simple, ok, not problem, but if you want a complex autoload engine it will consume a lot of memory.
My purpose is to define a new function like this:
function gl_class_exists($class) {
return in_array($class, get_declared_classes());
}
From now, each time you want to check if a class is declared, use this function. Of course, you will have to compare the autoloading method with this checking function; in my case is better to use this method.
Waiting your opinion!

