Welcome Guest, Not a member yet? Register   Sign In
get_instance problem

Hi everyone,
I'm trying to create a new Exceptions class for a little project I'm working on but I seem to have an issue with getting the CodeIgniter instance. The error I get is:

Quote:Fatal error: Call to undefined function get_instance() in ...

My code is this:

class HUB_Exceptions extends CI_Exceptions {
    private $CI;
    public function __construct() {
        $this->CI =& get_instance(); //It breaks on this line here...


This is my first time extending a core class, so I'm not 100% sure what's breaking here.

Any help would be greatly appreciated.


You are extending the core. I think you can dirtectly refer to the CI superobject as $this.

Doesn't look like I can, I tried this:

$this->session->set_item('error_heading', $heading);

and got another error:

Quote:Fatal error: Call to a member function set_item() on a non-object in...

[eluser]Shay Falador[/eluser]
Well, JoostV you are wrong, CI_Exceptions does not use the $this as we use it in controllers.

JCianflone, I guess the problem is that the Exceptions library is loaded BEFORE the base class is loaded and even it's filed loaded.
Therefor it doesn't exist yet..

Yea, that's what I was thinking.

OK, well, lets see if I can do this same thing with hooks!

@shay You're right, did not read the question well.

Theme © iAndrew 2016 - Forum software by © MyBB