I've read all the post I found regarding this issue but nothing works. I'm using Codeigniter 2.02 in a LAMP with Apache2.2 and PHP5.3.2
I'm trying to create a common controller from which my common controllers will inherit so I can do common tasks there.
I have this:
file: parent_controller.php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Parent_controller extends CI_Controller {
public function Parent_controller()
{
parent::__construct();
}
public function index() {
echo "Hi!";
}
}
file: welcome.php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends Parent_controller {
public function __construct()
{
parent::__construct();
}
}
I've tried the next solutions I've found, but none of them are working:
public function __contstruct() instead of public function Parent_controller()
parent::Parent_controller();
put the parent_controller.php file into core
put the parent_controller.php file into controllers
adding this to config/config.php:
function __autoload($class){ if (file_exists(APPPATH."(controllers|core)/".$class.EXT)){ require_once(APPPATH.'(controllers|core)/'.$class.EXT); } }
Thank you all.