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

[已解决] parent:Controller()出错。

[复制链接]
发表于 2011-4-2 17:52:43 | 显示全部楼层 |阅读模式
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Blog extends CI_Controller{
function Blog()
{
  parent::Controller();
  $this->load->scaffolding('entries');
}
function index()
{
  $data['title']="My Blog Title";
  $data['heading']="My Blog Heading";
  $data['todo']=array('clean house','eat lunch','call mom');
  $this->load->view('blog_view',$data);
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
?>
我下的是2.0.1版本。
运行提示:
Fatal error: Call to undefined method CI_Controller::controller() in G:\AppServ\www\codeigniter\application\controllers\blog.php on line 6
不知是何故?望高手指导指导。
发表于 2011-4-2 17:54:36 | 显示全部楼层
parent::__construct()

请阅读CI2.0更新日志
发表于 2011-4-2 17:55:21 | 显示全部楼层
并且scaffolding也在2.0中被废除
 楼主| 发表于 2011-4-2 17:57:18 | 显示全部楼层
谢谢,刚才看了一下system中的core目录,发现其中的Controller.php文件中无CI_Controller也无Controller,只有一个__construct()
 楼主| 发表于 2011-4-2 17:58:47 | 显示全部楼层
他是继承了CI_Controller这个类,然后调用父类的__construct()方法吗?
 楼主| 发表于 2011-4-2 18:01:24 | 显示全部楼层
回复 3# jeongee


    不好意思,新手,可不可以弱弱地问一下,更新日志在哪里呀?
发表于 2011-4-2 18:19:51 | 显示全部楼层
 楼主| 发表于 2011-4-6 11:08:25 | 显示全部楼层
回复 7# jeongee


    谢谢!
发表于 2011-4-8 13:10:26 | 显示全部楼层
手册很重要 、、、
发表于 2011-4-11 13:53:33 | 显示全部楼层
2.01不支持php4了,构造函数要改成:
PHP复制代码
 
function __construct()
{
     parent::__construct();
}
 
复制代码

本版积分规则