Error Class Controller not found in CodeIgniter(在 CodeIgniter 中找不到错误类控制器)
问题描述
您好,我在 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 中找不到错误类控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 CodeIgniter 中找不到错误类控制器
基础教程推荐
- 将变量从树枝传递给 js 2022-01-01
- php中的PDF导出 2022-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- php中的foreach复选框POST 2021-01-01
