How to use spl_autoload() instead of __autoload()

You need to register autoload functions with spl_autoload_register. You need to provide a “callable”. The nicest way of doing this, from 5.3 onwards, is with an anonymous function: spl_autoload_register(function($class) { include ‘classes/’ . $class . ‘.class.php’; }); The principal advantage of this against __autoload is of course that you can call spl_autoload_register multiple times, whereas … Read more

tech