2012-08-12 95 views
0

我有一个控制器名为blog.php在我的本地主机。要访问它,我在地址栏中键入http://localhost/ci/index.php/blog。在教程中它说它会显示Hello World,但我得到的显示是一个包含blog.php代码和404 Page Not Found的页面。codeigniter控制器加载

这是代码。

*<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
class Blog extends CI_Controller { 
    /** 
    * Index Page for this controller. 
    * 
    * Maps to the following URL 
    *  http://example.com/index.php/blog 
    * - or - 
    *  http://example.com/index.php/blog/index 
    * - or - 
    * So any other public methods not prefixed with an underscore will 
    * map to /index.php/blog/<method_name> 
    * @see http://codeigniter.com/user_guide/general/urls.html 
    */ 
    public function index() 
    { 
     echo "Hello World"; 
    } 
} 
/* End of file Blog.php */ 
/* Location: ./application/controllers/blog.php */* 

任何人请帮助我知道是什么问题。

+1

你可以发布config/config.php文件代码吗?也是http:// localhost/ci/working?它显示什么?而且你还没有在PHP之前使用*,对吧? – 2013-07-17 16:59:54

+0

yes Mr.web是正确的。您的codeigniter文件在ci文件夹内?尝试在google或SO上进行搜索,并找到相同的问题,您会发现很多问题和答案。 – 2014-11-16 18:14:20

回答

-1

您使用的是哪个版本的CodeIgniter,因为CI_Controller用于CI上的旧版本。你尝试做

class Blog extends Controller { 
} 

class Blog extends MY_Controller { 
} 

凡MY_在config.php文件中设置好的。

+1

其实并非如此。 CI使用CI_Controller仍然高达2.1.4。 MY_用于创建自己的类而不是控制器/视图/模型 – 2013-07-17 17:03:19

相关问题