0
votes

I don't how to solve this error. While using the following controller and views in the CodeIgniter-3.0.0 Version and i change the baseurl also too http://localhost/code/

controllers: Hello.php

  <?php
class Hello extends CI_Controller {
    var $name;
    var $color;
    function Hello()
    {
        $this->name = 'Andi';
        $this->color = 'red';
        parent::CI_Controller();
    }
    function you()
    {
        $data['name'] = $this->name;
        $data['color'] = $this->color;
        $this->load->view('you_view',$data);
    }

}
?>

View: you_view.php

    Hello You!
<font color="<?=$color ?>"><?=$name?></font>

http://localhost/code/index.php/Hello/you

Got an error:

 Fatal error: Call to undefined method CI_Controller::CI_Controller() in E:\phpprogram\code\application\controllers\hello.php on line 9
A PHP Error was encountered

Severity: Error

Message: Call to undefined method CI_Controller::CI_Controller()

Filename: controllers/hello.php

Line Number: 9

Backtrace:
3
Which version are you using ? - ltdev
CodeIgniter-3.0.0 version - Raja Manickam
Could you please suggest me any reference page too look for the solutions if u don't mind... Please because i have google many pages but its not worthy too study or learn that framework - Raja Manickam

3 Answers

2
votes

You should extend CI_Controller not Controller in controllers/Hello.php

0
votes

You need to replace Controller with CI_Controller.

Bookmark to your browser the user guide. It is something you will need to visit quite often. Most things are pretty well explained there.

0
votes

Try this on your controller:

class Hello extends CI_Controller {
    function hello()
    {
        parent::Controller();
    }

    function you()
    {
        $this->load->view('you_view');
    }
}