我有各种控制器core/
文件夹名为core/my_controller.php
和其他控制器libraries/
文件夹为libraries/user_controller.php
,。现在我使用下面的代码config.php
来自动加载这些文件。但我不认为它的工作。Codeigniter自动加载控制器不工作
我看到此错误消息Fatal error: Class 'MY_Controller' not found in /home/manumakeadmin/manumake.com/2d/application/libraries/frontend_controller.php on line 3
function __autoload($classname) {
if (strpos($classname, 'CI_') !== 0) {
$file = APPPATH . 'libraries/' . $classname . '.php';
if (file_exists($file) && is_file($file)) {
@include_once($file);
}
}
}
编辑
我可以把它通过手动包括文件作为
<?php
include_once APPPATH.'core/my_controller.php';
class Frontend_controller extends MY_Controller
{
工作,但如果我可以,我想知道使自动加载代码工作
非常感谢。 但是,一旦我在我的linux服务器上做了同样的事情,并且我收到错误消息,因为我使用大写字母的文件名来匹配它们与型号名称 – prakashchhetri 2013-05-03 05:41:05
不用担心!你是对的 - [模型文件名应该全部小写](http://ellislab.com/codeigniter/user-guide/general/models.html#anatomy)。检查用户指南中的命名惯例总是一个好主意。 – jleft 2013-05-03 07:51:15