更改了控制器加载位置,并且无法使用控制器中的任何功能

By default, as many of you probably know, codeigniter loads controllers from application/controllers (URI Segment 0). Well... I changed it so that it loads them fom application/modules/(URI Segment 0)/controllers/(URI Segment 1 / not set: URI Segment 0). Up to here it all works fine, but when I create a controller, I cannot use any of the default function as $this->load or etc... Example:

/**
* Home Controller Class
*/
class Home extends CI_Controller
{
    function __construct()
    {
        $this->load->database();
    }

    public function index()
    {
        echo "Testing...";
    }
}

This example would always result in an error:

Severity: Notice

Message: Undefined property: Home::$load

Filename: controllers/home.php

Line Number: 10

Well I don't know how you exactly changed the Controller location.

But when you extend the CI_Controller, and you use a constructor method, you need to execute the parent's __construct() method at first, as follows:

class Home extends CI_Controller
{
    function __construct()
    {
        /* Execute the CI_Controller constructor */
        parent::__construct();

        $this->load->database();
    }
}

That's because your local constructor will be overriding the one in the parent controller class. So you need to manually call it.

CodeIgniter Doc.

Similar topics on SO: