Khader
Khader

Reputation: 303

Code Igniter Inheritance error

Well i have defined a derived class from CI_Controller known as application that is present in the system/core/folder

<?php

Class Application extends CI_Controller {

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

} 

?>

and derived an class from application named as home which displays the home page

<?php


Class Home extends Application {


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

  public function index() {

     $this->load->view("Home");

  }

} 

?>

But i still get an error saying that Class 'Application' is not found

Upvotes: 0

Views: 47

Answers (1)

Mukesh Ram
Mukesh Ram

Reputation: 6328

Change core class name from 'Application' to 'MY_Controller'(class name must ends with _Controller) and save it as MY_Controller.php

Class MY_Controller extends CI_Controller {

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

} 

Then extend the application controller class

Class Home extends MY_Controller {

You can use any words instead of MY_. For this change the following line in config.php

$config['subclass_prefix'] = 'MY_';

Make sure only Uppercase letters are allowed.

Upvotes: 1

Related Questions