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

[已解决] 请教一个关于parent引用父类的问题

[复制链接]
发表于 2015-1-10 15:59:40 | 显示全部楼层 |阅读模式
新人第一次用CI框架,准备跟着视频教程学,中间有一部分:
class Blog extends CI_Controller{
    function Blog()
    {
        parent::CI_Controller();             //在网页上显示Call to undefined method CI_Controller::CI_Controller()

        $this->load->scaffolding('entries');
    }
    ...
}
请问是哪里出错了么?


 楼主| 发表于 2015-1-10 16:50:47 | 显示全部楼层
我在管理员Hex的CI入门中看到是由于php5的构造器前要加下划线,改成这样:
class Blog extends CI_Controller{
    function _Blog()                          //在Blog前加下划线
    {
        parent::CI_Controller();            

        $this->load->scaffolding('entries');
    }
    ...
}
这样就能运行了。
发表于 2015-1-11 21:00:13 | 显示全部楼层
__construct()

本版积分规则