Codeigniter - CI_Controller vs Controller Codeigniter - CI_Controller vs Controller codeigniter codeigniter

Codeigniter - CI_Controller vs Controller


In any version before 2, Controller is the base controller class (which you would extend with MY_Controller). In version 2 and up, you need to extend CI_Controller as this is the new name for the base controller class.

For anyone else coming across this, CI2 moved several class files from the /libraries to the new /core directory. If you take a look in system/core, every class you see there is now using the CI_ prefix - including Model (now CI_Model), Input, Loader, Lang, and many others. If you need to overload or extend these libraries, they now need to be in the application/core directory. You still will use the MY_ prefix to extend them, or whatever you have set in your $config['subclass_prefix'].

With the release of version 2, CI split into two branches: Core and Reactor. Don't be confused - they are both CodeIgniter, but any reference to "Reactor" is the current community driven version which is offered as the main download on the website, while Core is the older EllisLabs version with less features. From the CI website:

"Put simply, Reactor = CodeIgniter".

You can read more about the branch changes here.

Upgrading from 1.7.2 to 2.X is easy. As always, make sure to the read the change log and upgrade instructions when updating to a new version.

As far as the closing tag goes: it is optional, but you should avoid it when possible as it can introduce white space to the script (anything after the closing tag), which can mess up headers and appear in your output. As you know, the user guide recommends that you do not use it.


In CodeIgniter 2.x, the Controller class has been renamed to CI_Controller. The tutorial you're using is most likely using CodeIgniter 1.7 or earlier, when Controller was the correct class to extend.

Regarding the closing ?> tag, the CodeIgniter style guide recommends omitting it, since accidental white space after that tag can be problematic.