views:

261

answers:

2

Can I load a library from inside a helper?

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

Thanks, Max

A: 

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.

jimyi
I disagree with this. CI's own url helper loads the URI class.
Thorpe Obazee
A: 
// ------------------------------------------------------------------------
/**
 * URL String
 *
 * Returns the URI segments.
 *
 * @access  public
 * @return  string
 */
if ( ! function_exists('uri_string'))
{
    function uri_string()
    {
     $CI =& get_instance();
     return $CI->uri->uri_string();
    }
}

Yes, of course.

I disagree with jimyi's answer. CI's own url helper loads the URI class.

Thorpe Obazee