Advertisement
ralphschindler

Untitled

Aug 18th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. /**
  3.  * as a funciton file at My\autoload.php
  4.  * Usage:
  5.  *
  6.  * require_once 'My\Autoload.php';
  7.  * spl_autoload_register(new My\Autoloader);
  8.  */
  9.  
  10. namespace My;
  11.  
  12. class Autoloader {
  13.     public function __invoke($name) {
  14.         if (strpos($name, __NAMESPACE__ . '\\') !== 0) {
  15.             return;
  16.         }
  17.         // resolve class return true, if not
  18.     }
  19.     public function autoload($class) {
  20.         return $this->__invoke($class);
  21.     }
  22. }
  23.  
  24. ?>
  25.  
  26.  
  27. <?php
  28. /**
  29.  * as a function file at My\autoload.php
  30.  * Usage:
  31.  *
  32.  * spl_autoload_register(include 'My\autoload.php');
  33.  */
  34.  
  35. return function ($class) {
  36.     if (strpos($name, __NAMESPACE__ . '\\') !== 0) {
  37.         return;
  38.     }
  39.     // resolve class return true, if not
  40. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement