Skip to content

inheritance

Inheritance between controllers in Codeigniter

Today, we will talk about the inheritance between controllers in CodeIgniter. At first glance, it could seem very simple to do and it should not be more complicated than this:

class Parent_controller extends Controller {

    function __construct()
    {
       parent::Controller();
       ...
    }
    ...
}

class Child_controller extends Parent_controller {
    function __construct()
    {
        parent::__construct();
        ...
    }
    ...
}

If we run this code as it is, CodeIgniter will return an error saying that it can not find Parent_controller class, which I founded quite surprising.Read More »Inheritance between controllers in Codeigniter