Autoloader.php 462 B

1234567891011121314151617181920
  1. <?php
  2. if(!defined('ROOT_DIR'))
  3. {
  4. define('ROOT_DIR', realpath(__DIR__ . '/../') . '/');
  5. }
  6. function loadByNamespace($name)
  7. {
  8. $class_path = str_replace('\\', DIRECTORY_SEPARATOR ,$name);
  9. $class_file = ROOT_DIR . $class_path.'.php';
  10. if(is_file($class_file))
  11. {
  12. require_once($class_file);
  13. if(class_exists($name, false))
  14. {
  15. return true;
  16. }
  17. }
  18. return false;
  19. }
  20. spl_autoload_register('loadByNamespace');