AutoLoader.php 599 B

12345678910111213141516171819202122232425
  1. <?php
  2. class AutoLoader {
  3. private static $autoloadPathArray = array (
  4. "",
  5. "includes/",
  6. "api/",
  7. "token_share_example/"
  8. );
  9. public static function autoload($className) {
  10. foreach ( self::$autoloadPathArray as $path ) {
  11. $file = CURR_PATH . DIRECTORY_SEPARATOR . $path . $className . ".php";
  12. $file = str_replace ( '\\', DIRECTORY_SEPARATOR, $file );
  13. if (is_file ( $file )) {
  14. include_once $file;
  15. break;
  16. }
  17. }
  18. }
  19. public static function addAutoloadPath($path) {
  20. array_push ( self::$autoloadPathArray, $path );
  21. }
  22. }
  23. spl_autoload_register ( "AutoLoader::autoLoad" );
  24. ?>