Created
October 6, 2017 12:51
-
-
Save seriiserii825/789b1b9b34ad8d7a2daa201d1e80f7f4 to your computer and use it in GitHub Desktop.
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($className){ | |
//переводим в нижний регистр; заменяем обратные слеши. | |
$path = str_replace('\\', '/', $className).'.php'; | |
if(is_readable($path)){ | |
require_once ($path);//подключаем файл | |
}else throw new \DbException('Класс не найден: '.$path); | |
} | |
//регистрируем функцию | |
spl_autoload_register('autoload'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment