Guest User

Untitled

a guest
Dec 6th, 2012
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. /**
  2.  * Automatically load the given classes.
  3.  *
  4.  * Note: This function automaticly searches in the
  5.  * ./library/PhpBakery and ./app folder.
  6.  *
  7.  * @param string $className The name of the class to be loaded.
  8.  * @return boolean
  9.  */
  10. function __autoload($className) {
  11.     $className = ltrim($className, '\\');
  12.     $fileName = '';
  13.     $namespace = '';
  14.  
  15.     if ($pos = strripos($className, '\\')) {
  16.         $namespace = substr($className, 0, $pos);
  17.         $className = substr($className, $pos + 1);
  18.         $fileName = str_replace('\\', DS, $namespace) . DS;
  19.     }
  20.  
  21.     $fileName .= str_replace('_', DS, $className . EXT);
  22.  
  23.     if (file_exists(BASE_PATH . 'app' . DS . $fileName)) {
  24.         require (BASE_PATH . 'app' . DS . $fileName);
  25.         return TRUE;
  26.     } else {
  27.         require (SYS_PATH . $fileName);
  28.         return TRUE;
  29.     }
  30.  
  31.     return FALSE;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment