0

Got some error in codeigniter when trying to call parent class. This is what I did :

class Email extends CI_Controller
{
   function __construct()
   {
       parent::Controller();
   }
}

And this is the error :

Fatal error: Call to undefined method CI_Controller::Controller() in C:\xampp\htdocs\ci-nettuts-d3\application\controllers\email.php on line 11

3
  • Why is it CI_Controller instead of just Controller? Which version is this? I reckon it should be class Email extends Controller { ... but maybe it depends on release version... Commented Nov 30, 2011 at 6:44
  • The latest version is CI_Controller. You can refer here - codeigniter.com/user_guide/general/controllers.html Commented Nov 30, 2011 at 6:55
  • Well it seems like you need to use parent::__construct(); syntax as the answer suggested. Commented Nov 30, 2011 at 6:57

1 Answer 1

3

Which version of CI are you using? Tried parent::__construct(); instead of parent::Controller();?

Sign up to request clarification or add additional context in comments.

2 Comments

I watch this tutorial - net.tutsplus.com/articles/news/codeigniter-from-scratch-day-3 He use parent::Controller(); and he's code works! That's what me litte bit confuse
@Zhaf Probably they were using a code-igniter version that was compatible with php4. Latest codeigniter needs php 5.1.2. Here is some code on their documentation that suggests parent::__construct(), codeigniter.com/user_guide/general/controllers.html#reserved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.