用户
 找回密码
 入住 CI 中国社区
搜索
查看: 2847|回复: 2
收起左侧

[HELP] 关于创建核心类MY_Controller

[复制链接]
发表于 2012-7-16 16:48:07 | 显示全部楼层 |阅读模式
有点疑问,创建一个没有问题
PHP复制代码
class MY_Controller extends CI_Controller
复制代码

PHP复制代码
class example extends MY_Controller
复制代码

如果是多个
PHP复制代码
class MY_Controller1 extends CI_Controller
复制代码
PHP复制代码
class MY_Controller2 extends CI_Controller
复制代码

.。。。
这样在controllers中继承MY_Controller1或者MY_Controller2都会是 class not found
这是因为CI不允许这样做呢(为什么),或者是我写错了的原因
发表于 2012-7-16 17:25:01 | 显示全部楼层
你可以参考下源代码,你实际上是没有加载到文件的
PHP复制代码
        // Load the base controller class
        require BASEPATH.'core/Controller.php';
 
        function &get_instance()
        {
                return CI_Controller::get_instance();
        }
        if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
        {
                require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
        }
复制代码
 楼主| 发表于 2012-7-16 18:48:43 | 显示全部楼层
大道达人 发表于 2012-7-16 17:25
你可以参考下源代码,你实际上是没有加载到文件的

懂了,谢谢啊

本版积分规则