I have a controller named blog.php in my localhost. To access it I type http://localhost/ci/index.php/blog in addressbar. In the tutorial it said that it will display Hello World but the display I got is a page containing the blog.php code and 404 Page Not Found.
Here is the code.
*<?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 */*
anyone please help me to know what's the problem.
Which version of CodeIgniter are you using because the CI_Controller is for the older version on CI. Did you try to do
class Blog extends Controller {
}
or
class Blog extends MY_Controller {
}
Where MY_ is setted in your config.php file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.