Created
July 31, 2015 13:07
-
-
Save jaonoctus/bf60976cf3e6638a404c to your computer and use it in GitHub Desktop.
Função que carrega automaticamente as Classes e Interfaces no PHP
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
<?php | |
/** | |
* Função que carrega automaticamente as Classes e Interfaces | |
* Deve ser requerida em arquivos que usem as tecnologias acima. | |
* | |
* @param function($class) | |
*/ | |
spl_autoload_register( | |
function($class) { | |
// Remove "\" da variável $class e salva em $param | |
$param = explode("\\", $class); | |
// Salva o último índice do array $param em $class | |
$class = end($param); | |
// Inclui a Classe | |
require_once "$class.php"; | |
} | |
); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment