CodeIgniter Forums
Need for CI_ prefix when extending core libraries?? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Need for CI_ prefix when extending core libraries?? (/thread-26242.html)



Need for CI_ prefix when extending core libraries?? - El Forum - 01-09-2010

[eluser]mark-e-mark[/eluser]
I seem to be running into a little issue when I try to extend a core class.

The user guide suggests the following prototype to extend a core class:

Code:
class MY_CoreClass extends CI_CoreClass {

    function My_CoreClass()
    {
        parent::CI_CoreClass();
    }
}

.. where CoreClass is obviously replaced with the class I am trying to extend.

However, CI chucks a fatal error "Fatal error: Class 'CI_CoreClass' not found ....".

I CAN, however, get my extensions to work if I drop the CI_ prefix:

Code:
class MY_CoreClass extends CoreClass {

    function My_CoreClass()
    {
        parent::CoreClass();
    }
}

Is there something simple I'm doing wrong, or is there an error in the CI documentation?


Need for CI_ prefix when extending core libraries?? - El Forum - 01-09-2010

[eluser]WebsiteDuck[/eluser]
Which core class are you trying to extend?

I believe Model and Controller are not prefixed with CI_


Need for CI_ prefix when extending core libraries?? - El Forum - 01-09-2010

[eluser]mark-e-mark[/eluser]
Aaah. That may be it.

I'm trying to extend Model.