spl_autoload_register(function ($className)
{
if (file_exists($className . '.php'))
{
require_once($className . '.php');
}
else
{
throw new Exception('Could not load class: ' . $className);
}
});
//Load models and save them in variable instances
try
{
$this->database = new Database (
$config['DB']['HOST_IP'],
$config['DB']['DATABASE_NAME'],
$config['DB']['USERNAME'],
$config['DB']['PASSWORD']
);
//Set the initial language for our template model.
Template::setLanguage();
}
catch (Exception $e)
{
echo $e->getMessage();
}
如果我擦除脚本有效file_exists
,但file_exists
无论如何都会返回 false。
这可能是什么原因造成的?
另外,我收到一条错误消息:Uncaught exception 'Exception' with message 'Could not load class: Template'
. 是因为模板类是静态的吗?