I have a script that uses autoload to load classes that aren’t found. I don’t deliberately include the file (though I can) but I would like the autoload function to include the required files.
Because the script can be recursive, that is if the class is already loaded, I don’t want to check the corresponding file is loaded and if class_exists on each recursion of the script.
If you want to avoid
__autoload, you can userequire_onceinstead ofinclude.The performance hit of using
__autoloadmay be considerable, especially because some opcode caches do not support it properly. However, given it’s very handy, I’d say use it unless your opcode cache does not cache autoload includes.