I was going over some examples I found, including some on this forum on how to use spl_autoload_register()
So it looks like inside the custom autoload functions people ofter use something like this:
function customLoader($class){
// some code to find file path based on $class, assign it to $file
if(file_exists($file){
include_once($file);
return true;
}
return false;
}
What I’m thinking is that why use include_once here instead of just include()
I think that since php only calls autoload when it knows that class is not already loaded, this basically already takes care of the “include_once” logic, which is “don’t include file if its already been included”
Then it would make sense to never use include_once() inside your custom autoload function since include_once is more expensive than include()
Does this make sense or am I missing some important point?