Google News
logo
CodeIgniter - Interview Questions
How to load a helper in CodeIgniter?
* You need to load the helper files for using it. Once loaded, it will be globally available to your controller and views. They can be obtained at two places in CodeIgniter. A helper file will be searched by CodeIgniter in the application/helpers folder and if it is not available in that folder then it will check in the system/helpers folder.

* Helper file can be loaded by adding the following code to the constructor of the controller or inside any function that wants to use: $this->load->helper('file_name');
Write your file name at the place of file_name.

* To load URL helper we can use the code given below: $this->load->helper('url');

* You are allowed to auto-load a helper if your application needs that helper globally by including it in the application/config/autoload.php file.

* Loading multiple helpers is also possible. For doing this, specify them in an array as given below:
$this->load->helper(  
   array('helper1', 'helper2', 'helper3')  
);  
Advertisement