![]() |
i having a problem with parent - 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: i having a problem with parent (/showthread.php?tid=44142) |
i having a problem with parent - El Forum - 08-04-2011 [eluser]Unknown[/eluser] below is my code i am using php 5.2.11, on CI 2.02, and whenever i used the code "parent" i keep getting error.. <?php class Blog extends CI_Controller { function Blog() { parent::CI_Controller(); } function index() { $data['title']="my blog title"; $data['heading']="my blog heading"; $data['todo']= array('clean hosuse', 'eat lunch','call mom'); $this->load->view('blog_view', $data); } } ?> and i don't know what is wrong with "parent::CI_Controller();" here is the error "Parse error: syntax error, unexpected ':' in C:\wamp\www\loopfile\CodeIgniter_2.0.2\application\controllers\blog.php on line 8" i having a problem with parent - El Forum - 08-04-2011 [eluser]cahva[/eluser] Dont use PHP4 style constructors. I dont know if thats the actual problem but your constructor should look like this(replacing the function Blog() ): Code: function __construct() i having a problem with parent - El Forum - 08-06-2011 [eluser]toopay[/eluser] Unless you need to declare/define some variable or loading some common resources, you didn't need to declare a constructor. |