![]() |
parent::Controller() - 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: parent::Controller() (/showthread.php?tid=53348) |
parent::Controller() - El Forum - 07-20-2012 [eluser]rcahanap[/eluser] Hello! Someone suggested CodeIgniter for a project that I am doing, so I am currently going through the video tutorial right now that's on this site titled "Create a Blog in 20 Minutes". I am getting an error when I have this line: parent::Controller(); I looked online and someone suggested to replace it with this line and it was OK: parent::__construct(); I don't know enough about CodeIgniter to know that this is the right way to fix this error. The version I am using is 2.1.2. Thanks for your replies. -Roberto parent::Controller() - El Forum - 07-20-2012 [eluser]LuckyFella73[/eluser] Hi, the tutorial was written when we had Codeigniter version < 2. Up from CI 2 the CI Controller was renamed from "Controller" to "CI_Controller". So your controller class has to extend "CI_Controller" and Code: // change this Example from USER GUIDE: Code: <?php parent::Controller() - El Forum - 07-20-2012 [eluser]PhilTem[/eluser] If you used Code: parent::Controller(); with CI 2.1.2 it will most likely not work since CI 2.x renamed the class Controller to CI_Controller. So you would have to use Code: parent::CI_Controller(); The section question is only important if you're running PHP >= 5.3.3 or intend to running PHP >= 5.3.3 since, according to the PHP docu, a function called the same as your class will be treated as the constructor for PHP < 5.3.3 a separate function for PHP >= 5.3.3 It is recommended to use Code: parent::__consruct(); Therefore it all depends on the system you are or want to be running on. Some classes solve the problem in the following way: Code: class Someclass extends Someotherclass { parent::Controller() - El Forum - 07-20-2012 [eluser]rcahanap[/eluser] Ah OK, that explains it then. Thank you for the post. Wish me luck this weekend. I'll be creating some pages using Code Igniter! -Roberto parent::Controller() - El Forum - 07-20-2012 [eluser]boltsabre[/eluser] Good luck! It's a great framework once you get used to it!!! |