Php 类不自动加载?

Php 类不自动加载?,php,spl-autoload-register,Php,Spl Autoload Register,我的应用程序中有一个自动加载功能: spl_autoload_register(function ($className) { if (file_exists(ROOT . DS . 'library' . DS . 'intranet' . DS . 'classes' . DS .strtolower($className) . '.php')){ require_once(ROOT . DS . 'library' . DS . 'intranet' . DS . '

我的应用程序中有一个自动加载功能:

 spl_autoload_register(function ($className) {
if (file_exists(ROOT . DS . 'library'  . DS . 'intranet'  . DS  . 'classes' . DS .strtolower($className) . '.php')){
    require_once(ROOT . DS . 'library'  . DS . 'intranet'  . DS  . 'classes' . DS .strtolower($className) . '.php');
    print_r($className." loaded <br/>");
} else if (file_exists(ROOT . DS . 'application' . DS . 'controller' . DS . strtolower($className) . '.php')) {
    require_once(ROOT . DS . 'application' . DS . 'controller' . DS . strtolower($className) . '.php');
} else if (file_exists(ROOT . DS . 'application' . DS . 'model' . DS . strtolower($className) . '.php')) {
    require_once(ROOT . DS . 'application' . DS . 'model' . DS . strtolower($className) . '.php');
} else if (file_exists(ROOT . DS . 'application' . DS . 'view' . DS . strtolower($className) . '.php')) {
    require_once(ROOT . DS . 'application' . DS . 'view' . DS . strtolower($className) . '.php');
} else {
    throw new Exception("Class: $className not autoloaded!");
}
});
看起来好像正在加载,对吗

在sessionnmanager类中:

Fatal error: Class 'database' not found 
我的自动装弹机看起来好吗


我已经在
\uu construct
方法中的数据库类中放置了一个print,是的,确实,它正在被调用

您是否有两个数据库文件,并且由于冲突,自动加载程序加载的是错误的文件?不应该有,但我已经查看了,项目中只有一个。您是否检查了库/intranet/classes/database.php文件?它是否包含类“database”的声明?似乎不是这样。@ElenaSharovar应用程序在本地运行得非常好
/library/intranet/classes/database.php
存在并且只包含一个声明您不应该在自动加载程序中记录异常,因为如果您(或您使用的库)注册另一个异常,它将永远不会被调用。
Fatal error: Class 'database' not found