title: Is there a way to dynamically change the name of the class being autoloaded?
body: <p>For instance, say I have the following code.</p>
  
  <pre><code>$foo = new bar();
  </code></pre>
  
  <p>And an autoloader like this.</p>
  
  <pre><code>function autoload($class_name) {
      $class_file_name = str_replace('_', '/', $class_name) . '.php';
      if (file_exists($class_file_name)) {
          include($class_file_name);
      }
  }
  </code></pre>
  
  <p>But the class I really want to load is in the folder 'foo/bar.php', and the real class name is actually foo_bar. Is there a way to dynamically change the name of the class being autoloaded? For instance, something like this?</p>
  
  <pre><code>function autoload(&amp;$class_name) {
      $class_name = 'foo_' . $class_name;
      $class_file_name = str_replace('_', '/', $class_name) . '.php';
      if (file_exists($class_file_name)) {
          include($class_file_name);
      }
  }
  </code></pre>
  
  <p>I know if something like this is possible, it is not exactly best practice, but I would still like to know if it is.</p>