If there must be multiple autoload functions, spl_autoload_register() allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined. By contrast, __autoload() may only be defined once.
If there must be multiple autoload functions,
spl_autoload_register()
allows for this. It effectively creates a queue of autoload functions, and runs through each of them in the order they are defined. By contrast,__autoload()
may only be defined once.spl_autoload_register
可以很好地处理需要多个加载器的情况,这种情况下spl_autoload_register
会按顺序依次调用之前注册过的加载器。作为对比,__autoload
因为是一个函数,所以只能被定义一次。