Can I load a library from inside a helper?
$this->load->library('name');
Thanks, Max
The main difference between Helper and Library in CodeIgniter is that Helper is a file with a set of functions in a particular category and is not written in Object Oriented format, while the Library is a class with a set of functions that allows creating an instance of that class and is written in Object Oriented ...
They are simple, procedural functions. Each helper function performs one specific task, with no dependence on other functions. CodeIgniter does not load Helper Files by default, so the first step in using a Helper is to load it. Once loaded, it becomes globally available in your controller and views.
To use helper files, you need to load it. Once loaded it is globally available to your controller and views. They are located at two places in CodeIgniter. CodeIgniter will look first for a helper in application/helpers folder and if not found there then it will go to system/helpers folder.
Loading the Custom LibraryUse the name of the library without “. php” extension. After loading the library, you can also call the function of that class as shown below.
function sendEmail() { $CI =& get_instance(); $CI->load->library('email'); // load library }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With