Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9085805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:20:06+00:00 2026-06-16T21:20:06+00:00

Possible Duplicate: Codeigniter extending extended MY_Controller I have been fiddling with this problem for

  • 0

Possible Duplicate:
Codeigniter extending extended MY_Controller

I have been fiddling with this problem for a while now, and am at the point of frustration. I am extending the controller class with MY_Controller.

Here are the details:

  • __construct() does not seem to be called.
  • The file is located in application/core as it should be
  • The file is named MY_Controller.php
  • I have MY_ set up as the prefix for extensions (I have other extensions which work fine)

Here is my code:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        echo 'TESTING!!!'; // This should print, followed by an ob_start() error
    }

}

I should get a page back that says TESTING!!! followed by an ob_start() error, but instead the page renders normally.

I have tried splitting up the constructor class and just calling a private function within MY_Controller, but that doesn’t work. I know the file is being called because if I purposefully create a php error within MY_Controller.php, the page will error out. It seems to me that the __construct() is just not running.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:20:07+00:00Added an answer on June 16, 2026 at 9:20 pm

    Can you show an example of one your controllers under application/controllers? Pls note that the controllers under application/controller should extend MY_Controller instead of CI_Controller – I think this is what you missed.

    For example, under your controller application/controller/test.php. it should look like this:

    class Test extends MY_Controller {        
        public function index()
        {
             echo 'test';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Problem with database in CodeIgniter Alright, I've googled this the last two
Possible Duplicate: Codeigniter global_xss_filtering I have small problem with inserting image source (HTML tag)
Possible Duplicate: Codeigniter 2 forms on one page, validation_errors problem I have 2 forms
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: CodeIgniter Disallowed Key Characters Im trying to have a form submit to
Possible Duplicate: Floating point division vs floating point multiplication recently, i have written a
Possible Duplicate: How to make dynamic form action address in codeigniter? I have the
Possible Duplicate: url encoded forward slashes breaking my codeigniter app This is my controller:
Possible Duplicate: CodeIgniter Disallowed Key Characters I have a bit of an issue with
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.