![]() |
Constructor Not Working - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Constructor Not Working (/showthread.php?tid=37160) |
Constructor Not Working - El Forum - 12-30-2010 [eluser]oldrock[/eluser] Hi .., I am using constructor for the first time the following code is not working while giving the url:http://localhost/code/index.php/archives <?php class Archives extends Controller { function Archives() { parent::controller(); $this->load->view('head'); } } ?> thanks in advance Constructor Not Working - El Forum - 12-30-2010 [eluser]Atharva[/eluser] Of course it will not work. Code: http://localhost/code/index.php/archives This will look for index function in archives controller which you haven't written. You have to write index function in archives controller in which you will load the view. Also, you should get your basics updated. Constructors are not meant for loading a view, they meant for constructing values (objects) that you may need in further processing. |