codeigniter correct way to check if libraries/helper/core files is loaded

this is codeigniter method to check the loaded libraries.

//If the library is not loaded, Codeigniter will return FALSE
if(!$this->load->is_loaded('session'))
{
     $this->load->library('session');
} 

You can use the native PHP function class_exists() to determine if the class has been defined, before calling it. In same regard, using method_exists() will check if class method exists.

Since helpers are collection of function, not methods, checking can be done using function_exists().

if (class_exists('Library')) 
{
    $this->library->myMethod();
}

For further info please refer to

http://php.net/manual/en/function.class-exists.php.

http://us.php.net/manual/en/function.method-exists.php


You don't have to check, you just load them wherever you need to be sure to have them.

Using CI's Load library ($this->load->[library|model|helper]) will always load it just once. You can see this if you turn on your debug logging.