<?php
class Blog extends CI_Controller {
function Blog() {
parent::CI_Controller();
}
}
I'm trying to create a constructor in Code Igniter for my class 'Blog' and the above code is giving me a fatal error:
Fatal error: Call to undefined method CI_Controller::CI_Controller() in C:\xampp\htdocs\mysites\blog\application\controllers\blog.php on line 5
How do I fix this?
(I'm going through 开发者_StackOverflow社区a online video tutorial on the official code igniter website but I think the tutorial is about 2 years out of date as some of the things are not working when I follow them exactly as shown in the video, this being one of them - the link to the video is here - I encounter this problem towards the end of the tutorial about 8 minutes in)
It should be this...
<?php
class Blog extends CI_Controller {
function __construct() {
parent::__construct();
}
}
The tutorial you are probably going through is based on 1.7.2 which had a core of php4 which did not use the php5 __construct()
method of building Class constructors. Codeigniter 2.0.0 has a php5 core and uses it.
精彩评论