【发布时间】:2012-08-12 06:19:06
【问题描述】:
我的本地主机中有一个名为 blog.php 的控制器。要访问它,我在地址栏中键入 http://localhost/ci/index.php/blog。在教程中它说它将显示 Hello World 但我得到的显示是一个包含 blog.php 代码和 404 Page Not Found 的页面。
这里是代码。
*<?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 */*
请大家帮我看看有什么问题。
【问题讨论】:
-
能否贴出config/config.php文件代码? localhost/ci 还在工作吗?它显示什么?而且你没有在 PHP 之前使用 *,对吧?
-
是的 Mr.web 是对的。你在 ci 文件夹中的 codeigniter 文件?尝试在 google 或 SO 搜索同样的问题,你会发现很多问题和答案。
标签: php codeigniter controller load