title: How to autoload PHP 5.3 classes?
body: <p>I am trying to autoload my PHP 5.3 namespaced classes eg. </p>
  
  <pre><code>/JM
      Auth.php
      User.php
      Db/Entity.php
      / ...
  </code></pre>
  
  <p>I did </p>
  
  <pre><code>namespace KM;
  
  class Autoloader {
      public static function registerAutolaod() {
          ini_set('include_path', dirname(__FILE__) . PATH_SEPARATOR . ini_get('include_path'));
          spl_autoload_register(function ($classname) {
              $file = preg_replace('/\\\/', DIRECTORY_SEPARATOR, $classname) . '.php';
              echo $file . '&lt;br /&gt;';
              include ($file);
  
          });
      }
  }
  </code></pre>
  
  <p>Problem is sometimes I get classname as <code>User</code> sometimes <code>KM\User</code> how can I fix this?</p>