您好,我在 CodeIgniter 中遇到 Controller
not found 错误.这是我的控制器代码
Hello, I am getting Controller
not found error in CodeIgniter. This is my Controller code
<?php
class HelloWorld extends Controller
{
function HelloWorld()
{
parent::Controller();
}
function index()
{
$this->load->view('index_view');
}
function hello()
{
$this->load->view('hello_view');
}
}
?>
这是视图代码:
你好,很高兴见到你!
执行时出现此错误:
致命错误:在第 2 行的 D:wampwwwCodeIgniter_2.0.2applicationcontrollershelloworld.php 中找不到 Class 'Controller'
谁能告诉我为什么会出现这个错误?
Can anyone tell me why I get this error?
从 CodeIgniter 2.x 开始,CI_
前缀被添加到所有核心类中.检查更改日志.
As of CodeIgniter 2.x CI_
prefix is added to all core classes. Check the Change Log.
为所有核心类添加了 CI_ 前缀.
对于 CodeIgniter 2.x
For 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');
}
}
对于 CodeIgniter 1.x
For 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');
}
}
希望对你有帮助.谢谢!!
Hope this helps you. Thanks!!
这篇关于在 CodeIgniter 中找不到错误类控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!