Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * as a funciton file at My\autoload.php
- * Usage:
- *
- * require_once 'My\Autoload.php';
- * spl_autoload_register(new My\Autoloader);
- */
- namespace My;
- class Autoloader {
- public function __invoke($name) {
- if (strpos($name, __NAMESPACE__ . '\\') !== 0) {
- return;
- }
- // resolve class return true, if not
- }
- public function autoload($class) {
- return $this->__invoke($class);
- }
- }
- ?>
- <?php
- /**
- * as a function file at My\autoload.php
- * Usage:
- *
- * spl_autoload_register(include 'My\autoload.php');
- */
- return function ($class) {
- if (strpos($name, __NAMESPACE__ . '\\') !== 0) {
- return;
- }
- // resolve class return true, if not
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement