parent::Controller() |
[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
[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
[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 {
[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
[eluser]boltsabre[/eluser]
Good luck! It's a great framework once you get used to it!!! |
Welcome Guest, Not a member yet? Register Sign In |