I’m a complete beginner in CodeIgniter. I’m trying to understand the MVC pattern,which is getting a bit trickier as I’m going ahead with CodeIgniter.
This is what my Controller looks like i.e hello.php :
<?php
class hello extends CI_Controller
{
var $name;
var $color;
function hello()
{
parent::Controller();
$this->name ='Leroy';
$this->color ='red';
}
function show()
{
$data['name'] =$this->name;
$data['color']=$this->color;
$this->load->view('show_message',$data);
}
}
?>
the view i.e show_message.php
<p align="center">Hello <font color="<?=$color?>"><?=$name?></font>..!!!!.</p>
when I run this script it gives this error
Fatal error: Call to undefined method CI_Controller::Controller() in C:\xampp\htdocs\CodeIgniter\application\controllers\hello.php on line 8
P.S I’m using CodeIgniter version 2.0 so I changed the class name to CI_Controller
Replace your constructor code with this