1
0

psr0.php 892 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * Sample PSR-0 autoloader.
  4. *
  5. * Do not use as such: it is only present to demo classes in a PSR-0 context.
  6. *
  7. * Straight from the PSR-0 standard.
  8. *
  9. * @link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
  10. *
  11. * @param string $className
  12. */
  13. function psr0_autoload($className) {
  14. $className = ltrim($className, '\\');
  15. $fileName = '';
  16. $namespace = '';
  17. if ($lastNsPos = strripos($className, '\\')) {
  18. $namespace = substr($className, 0, $lastNsPos);
  19. $className = substr($className, $lastNsPos + 1);
  20. $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
  21. }
  22. $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
  23. /*
  24. $stack = array_slice(debug_backtrace(), 2, 1);
  25. $stack = reset($stack);
  26. unset($stack['args']);
  27. print_r($stack);
  28. */
  29. $sts = @include $fileName;
  30. return $sts;
  31. }