Every time CodeIgniter runs there are several base classes that are
initialized automatically as part of the core framework. It is possible,
however, to swap any of the core system classes with your own versions
or even extend the core versions.

Most users will never have any need to do this, but the option to
replace or extend them does exist for those who would like to
significantly alter the CodeIgniter core.

Note

Messing with a core system class has a lot of implications, so
make sure you know what you are doing before attempting it.

If all you need to do is add some functionality to an existing library -
perhaps add a method or two - then it’s overkill to replace the entire
library with your version. In this case it’s better to simply extend the
class. Extending a class is nearly identical to replacing a class with a
couple exceptions:

The class declaration must extend the parent class.

Your new class name and filename must be prefixed with MY_ (this
item is configurable. See below.).

For example, to extend the native Input class you’ll create a file named
application/core/MY_Input.php, and declare your class with:

classMY_InputextendsCI_Input{}

Note

If you need to use a constructor in your class make sure you
extend the parent constructor:

Tip: Any functions in your class that are named identically to the
methods in the parent class will be used instead of the native ones
(this is known as “method overriding”). This allows you to substantially
alter the CodeIgniter core.

If you are extending the Controller core class, then be sure to extend
your new class in your application controller’s constructors.