Ume*_*era 3 php controller codeigniter class
您好,我Controller在CodeIgniter中找不到错误.这是我的控制器代码
<?php
class HelloWorld extends Controller
{
function HelloWorld()
{
parent::Controller();
}
function index()
{
$this->load->view('index_view');
}
function hello()
{
$this->load->view('hello_view');
}
}
?>
Run Code Online (Sandbox Code Playgroud)
这是视图代码:
Hello, Nice to see you!
执行时出现此错误:
Fatal error: Class 'Controller' not found in D:\wamp\www\CodeIgniter_2.0.2\application\controllers\helloworld.php on line 2
谁能告诉我为什么会出现这个错误?
从CodeIgniter开始,2.x CI_前缀被添加到所有核心类.检查更改日志.
Added CI_ Prefix to all core classes.
对于CodeIgniter 2.x
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class HelloWorld extends CI_Controller
{
function __construct()
{
parent::__construct();
}
function index()
{
$this->load->view('index_view');
}
function hello()
{
$this->load->view('hello_view');
}
}
Run Code Online (Sandbox Code Playgroud)
对于CodeIgniter 1.x
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class HelloWorld extends Controller
{
function HelloWorld()
{
parent::Controller();
}
function index()
{
$this->load->view('index_view');
}
function hello()
{
$this->load->view('hello_view');
}
}
Run Code Online (Sandbox Code Playgroud)
希望这对你有所帮助.谢谢!!