Welcome Guest, Not a member yet? Register   Sign In
i having a problem with parent
#1

[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"
#2

[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()
{
  parent::__construct();
}
#3

[eluser]toopay[/eluser]
Unless you need to declare/define some variable or loading some common resources, you didn't need to declare a constructor.




Theme © iAndrew 2016 - Forum software by © MyBB