Created
October 1, 2019 07:58
-
-
Save Guley/e415476a534e9d61c2fd9c140b8406cd to your computer and use it in GitHub Desktop.
Codeginter 3 check if class exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function callexistclass(){ | |
$CI = & get_instance(); | |
$file_name = 'Test'; | |
$file_path = APPPATH.'controllers/' . $file_name . '.php'; | |
$object_name = $file_name; | |
if (file_exists($file_path)) { | |
require $file_path; | |
$CI->$object_name = new $object_name(); | |
var_dump($CI->$object_name); | |
} | |
else { | |
show_error('Unable to load the requested controller class: ' . $object_name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment