How to check if a library exist in a controller? |
PHP Code: if(file_exists("../libraries/myapp/" . ucfirst($library_name).".php")) { This code is not working for me. It is written inside of a controller. I have a default library and some special libraries. If special libraries are just the controller names. If they exist, they should be loaded. Or the default one should be loaded. PHP Code: if(file_exists("../libraries/myapp/" . ucfirst($library_name).".php")) { What is the right way to check the existence of a library?
Check if object is available:
PHP Code: $is_loaded = is_object(@$this->upload) ? TRUE : FALSE;// @ sign suppressed error if object didn't exist Now you just need to make your own method that take a parameter as name of library: PHP Code: private function is_lib($lib) PHP is_object function.
I understand that you want first to check if library loaded.
If not than you need to load, else you just use that library: PHP Code: public function some_other_method() |
Welcome Guest, Not a member yet? Register Sign In |