Skip to content

Instantly share code, notes, and snippets.

@RafaPegorari
Created June 22, 2015 12:06
Show Gist options
  • Save RafaPegorari/71b64099d9669029c60c to your computer and use it in GitHub Desktop.
Save RafaPegorari/71b64099d9669029c60c to your computer and use it in GitHub Desktop.
multiple __autoload
function __autoload($class_name) {
$exp = explode("_", $class_name);
if(($exp_length = count($exp)) > 1){
$file = ABSPATH . '/bases/lib/';
foreach($exp as $key=>$val){
if(($exp_length-1) == $key){
$file .= $val.'.class.php';
}else{
$file .= $val.'/';
}
}
}else{
$file = ABSPATH . '/bases/classes/' . $class_name . '.class.php';
}
if (!file_exists($file)) {
require_once ABSPATH . '/sistema/conteudo/erros/404.phtml';
return;
}
// Inclui o arquivo da classe
require_once $file;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment