我真的没有得到 spl_autoload 的文档
bool spl_autoload_register ([ callback $autoload_function ] )
据我了解,当 php 遇到尚未加载的类时,它将尝试运行注册的函数。例如,
public function autoload() {
require ('nonLoadedClass.php');
}
spl_autoload_register(autoload);
$x = new nonLoadedClass();
会导致要求运行吗?所以我也可以注册许多自动加载功能?
public function autoloadXXX() {...}
public function autoloadYYY() {...}
public function autoloadZZZ() {...}
spl_autoload_register('autoloadXXX');
spl_autoload_register('autoloadYYY');
spl_autoload_register('autoloadZZZ');
在教义的情况下,
require_once(dirname(__FILE__) . '/lib/vendor/doctrine/Doctrine.php');
spl_autoload_register(array('Doctrine', 'autoload'));
传递了一个数组,所以我猜它会尝试在 Doctrine 类中运行自动加载函数(这是必需的)?