Skip to content

Instantly share code, notes, and snippets.

@Guley
Created October 1, 2019 07:58
Show Gist options
  • Save Guley/e415476a534e9d61c2fd9c140b8406cd to your computer and use it in GitHub Desktop.
Save Guley/e415476a534e9d61c2fd9c140b8406cd to your computer and use it in GitHub Desktop.
Codeginter 3 check if class exist
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