title: AutoLoading Multiple Classes Within A Class
body: <p>What's the correct way to use the <code>spl_autoload_register</code> function in PHP within a class to load other classes.</p>
  
  <p>What I want to do, is have a single class which has a bunch of functions that I can call which autoloads the required files when needed.</p>
  
  <p>This is what I'm trying to do: </p>
  
  <p><strong>myClass.php</strong></p>
  
  <pre><code>class myClass {
  
      public function test() {
          return "blah blah ";
      }
  
  }
  </code></pre>
  
  <p>and then my class which loads other classes:
  <strong>boot.php</strong></p>
  
  <pre><code>class boot {
  
  
      public static function autoloader($className)
  
      {
           $class = str_replace("\\", "/", $className);
           $filename = __DIR__."/".$class . ".php";
           if (is_readable($filename)) {
                require $filename;
          }
      }
  
       public static function registerAutoloader()
          {
                  spl_autoload_register(__CLASS__ . "::autoloader");
          }
  
      public function loadClass() 
      {
          $classname = new myClass();
          return $classname;
  
      }
  
  }
  </code></pre>
  
  <p>And then I load it like this:</p>
  
  <pre><code>require "boot.php";
  boot::registerAutoloader();
  $boot = new boot();
  $class = $boot-&gt;loadClass();
  var_dump($class-&gt;test());
  </code></pre>
  
  <p>However I'm getting "Fatal error: Class 'myClass' not found in boot.php. Can someone help, what's the correct way of doing this?</p>