Calling a library from inside a helpers function in Codeigniter


Question

Can I load a library from inside a helper?

$this->load->library('name');

Thanks, Max

1
21
8/30/2009 9:47:29 PM

Accepted Answer

No. The purpose of helpers is to "perform one specific task, with no dependence on other functions."

Quoted from CI's helpers page.

If you need to include a library inside of your helper, consider making it a library instead.

-8
8/30/2009 9:52:46 PM

function sendEmail() {
     $CI =& get_instance();
     $CI->load->library('email'); // load library 
}

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon