![]() |
Beginner question - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Beginner question (/showthread.php?tid=42529) |
Beginner question - El Forum - 06-09-2011 [eluser]Uplift[/eluser] I am in the process of learning CI but one thing i'm just not sure what it's for Code: class Welcome extends CI_Controller { parent::__construct(); .. what it is this for, what is it actually doing? I've removed it from my code and it still works fine. I've checked a few guides, most say it's needed but nothing more. Beginner question - El Forum - 06-09-2011 [eluser]WanWizard[/eluser] The Welcome class extends the CI_Controller class. parent::__construct() calls the constructor of the parent class. What is does depends on the code in that constructor. Beginner question - El Forum - 06-09-2011 [eluser]cideveloper[/eluser] personally I use constructors to do things that will be needed before running any functions in the class. specifically I use it to load libraries, helpers and models that I know will be used in all or most of my functions. I also like to throw this Code: //$this->output->enable_profiler(TRUE); in the constructor. That way If I am having problems I just uncomment it and all the functions will show the profiler. |