Created
June 22, 2015 12:06
-
-
Save RafaPegorari/71b64099d9669029c60c to your computer and use it in GitHub Desktop.
multiple __autoload
This file contains 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
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