Helpers in codeigniter
According to the Name suggested "Helper" are the files which help us with tasks. Helpers are the collection of same category methods in a file. Each helper file is simply a collection of functions in a particular category.
One of them is URL Helpers, it assist us in creating links, another are is Form Helpers which help to create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help us to deal with files, etc.
*Loading helper: * You can load the helper in your controller by the following syntex.
$this->load->helper('helper_name');
You can call the helper inside a method and for all methods in a controller you can call this inside the __constructor of controller.
For example, load url, form and session helper, you can write 2 lines-
$this->load->helper('url');
$this->load->helper('form');
$this->load->helper('session');
Or you can call all these only with one line-
$this->load->helper(array('url', 'form', 'session'));
0 Comment(s)