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 中找不到错误类控制器
				
        
 
            
        - 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
 - PHP - if 语句中的倒序 2021-01-01
 - 如何在 Symfony2 中正确使用 webSockets 2021-01-01
 - 覆盖 Magento 社区模块控制器的问题 2022-01-01
 - openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
 - 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
 - Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
 - Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
 - PHP foreach() 与数组中的数组? 2022-01-01
 - 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
 
