require __DIR__.'/../vendor/autoload.php' 自动加载先加载为什么要加载这么类呀?
index.php 文件中:
require __DIR__.'/../vendor/autoload.php';
ClassLoader.php 文件中
/**
* Loads the given class or interface. * * @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
这个做的目的是
在new 一个对象的时候,会调用 loadClass 方法,loadClass 方法会在之前已经加载的文件中查找吗(在 autoload_static.php文件已经加载)吗
autoload_static.php 文件
class ComposerStaticInit9093630b1d1df41a95a88e872dd08364 {}
推荐文章: