CodeIgniter中找不到错误类控制器 [英] Error Class Controller not found in CodeIgniter

查看:188
本文介绍了CodeIgniter中找不到错误类控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在CodeIgniter中得到 Controller 未找到错误。这是我的控制器代码

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');
    }

}
?>

这是视图代码:

您好,很高兴见到您!

执行时出现此错误:

致命错误:在D:\wamp\www\CodeIgniter_2.0.2\ application\controllers\helloworld.php中找不到类'Controller' 2

任何人都能告诉我为什么会收到此错误?

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中找不到错误类控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆