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

[已解决] 新手遇困3天了, Class 'CI_Controller' not found

[复制链接]
发表于 2012-1-12 10:48:33 | 显示全部楼层 |阅读模式
本帖最后由 xygs888 于 2012-1-15 11:20 编辑

求大侠们帮助吖
Fatal error: Call to undefined method CI_Controller::controller() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ci\application\controllers\navgate.php on line 7

代码

<?php
class Blog extends CI_Controller {

function __construct()
{
  parent::__construct();
}

function index()
{
  echo '你好,世界!';
}

function comments()
{
  echo '看这里!';
}
}
?>
发表于 2012-1-12 10:49:59 | 显示全部楼层
什么版本?
 楼主| 发表于 2012-1-12 10:59:27 | 显示全部楼层
2.10。。超级不解
 楼主| 发表于 2012-1-12 11:05:20 | 显示全部楼层
贴上代码,是看视频 20分钟blog的,完全一样的<?php

class Blog extends CI_Controller {

function Blog()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
       
        }

        public function index()
        {
                //$this->load->view('welcome_message');
                $data['title']="My blog title";
                $data['heading']="My blog heading";
                $data['query']=$this->db->get('entries');
               
                $this->load->view('blog_view',$data);
        }
       
        function comments()
        {
               
                $data['title']="My Comment Title222";
                $data['heading']="My Comment Heading222";
               
                $this->load->view('comment_view',$data);
        }
        function comment_insert()
        {
                $this->db->insert('comments',$_post);
                redirect('blog/comments/'.$_POST['entry_id']);
                }
}
?>


发表于 2012-1-12 11:29:41 | 显示全部楼层
xygs888 发表于 2012-1-12 11:05
贴上代码,是看视频 20分钟blog的,完全一样的

贴上目录结构看看。
发表于 2012-1-12 11:30:50 | 显示全部楼层
\controllers\navgate.php
但是你的class为啥是Blog,应该是class Navgate
发表于 2012-1-12 13:02:17 | 显示全部楼层
文件名和类名要一致
发表于 2012-1-12 16:16:15 | 显示全部楼层
parent::Controller();  也错了
 楼主| 发表于 2012-1-12 16:29:41 | 显示全部楼层
谢谢,解决了
发表于 2012-2-1 18:20:16 | 显示全部楼层
xygs888 发表于 2012-1-12 16:29
谢谢,解决了

怎么解决的?我也遇到了类似的问题

本版积分规则