CodeIgniter Helper functions are used to develop your system or in other words, it will help you to build your system. Helper functions are a combination of different small functionalities to entertain multiple features.

For the individual feature, there is an individual helper function is available in CodeIgniter. Even that we can build our own helper functions for custom features.

Each helper file is a combination of helper functions which will entertain in a particular sector all feature within CodeIgniter. Such as for URL there is URL helper which will help the application to develop the clean URL.

There is an important point Which you need to know about CodeIgniter helper is that it is not developed in object-oriented format. Instead, helpers wrote in a procedural function format.

As we have already learned that each helper is for a unique purpose having no dependency on any other component of the application.

By default, CodeIgniter will not load any helper. So if you want to use any helper of CodeIgniter you have to load that before using its functions. Even that you can autoload a helper if you need that in the whole application such as URL helper or cookie helper.

Helpers are by default available in “system/helpers” or in “application/helpers” folder. When CodeIgniter executed first it will search the helpers in “application/helpers” and if the required helper not exists then search in “system/helpers” folder.

Loading Helper

Following is the syntax of loading a helper within your application. Mostly it is loaded under the controller.


Loading Helper in Controller

   class CodeigniterController extends CI_Controller{

   	public function index() { 
         echo "Welcome to";


Auto-loading Helper

If you want to declare a helper as a global scope in your whole application. Then you have to define that in “autoload.php” as we have defined in the following code.

| -------------------------------------------------------------------
|  Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|	$autoload['helper'] = array('url', 'file');
$autoload['helper'] = array('url','file','form','email');

The helper can be loaded within a controller or within view. Loading helper within view is a not a good practice but you can do that. Mostly developer load helper within the constructor of controllers.

By loading helper within the constructor of controller, it will be available for all the methods within that controller. If you need a helper for a specific method then you can declare within in individual method having a limited scope.