i'm using codeigniter 2.
Appreciate if someone could show the correct way to check if the following files :
- library file is loaded?
- helper file is loaded?
- config file is loaded?
- model file is loaded?
- third_party file is loaded?
regards
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.
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