title: __autoload with namespace class gives fatal error for file not found
body: <p>I was going through the <code>__autoload</code> feature that <code>PHP</code> provides.</p>
  
  <p>However this is the <code>index.php</code> I have:-</p>
  
  <pre><code>define('app_path', realpath('../'));
  
  $paths = array(
          app_path, get_include_path());
  set_include_path(implode(PATH_SEPARATOR, $paths));
  
  function __autoload($classname)
  {
      $filename = str_replace('\\', '/', $classname.'.php');
      require_once $filename;
  }
  
  use \engine\controllers as Controllers;
  
  $data = new Controllers\base(); // This one is line no. 25 (Here is error)
  echo $data-&gt;mind('Hi');
  </code></pre>
  
  <p>And this one as my <code>base.php</code>:-</p>
  
  <pre><code> namespace controllers;
   class base {
      public function __construct() {
          echo __CLASS__ . '&lt;br/&gt;';
          echo __NAMESPACE__;
      }
  
      public function mind($myname)
      {
          echo $myname;
      }
   }
  </code></pre>
  
  <p>and throws this error:</p>
  
  <p><img src="https://i.stack.imgur.com/R5je9.png" alt="enter image description here"></p>
  
  <p>My directory structure is as follows:</p>
  
  <p><code>app -&gt; engine -&gt; controller -&gt; base.php</code></p>
  
  <p><code>app -&gt; index.php</code></p>
  
  <p>I am not sure whats wrong is happening. I am just learning how to use <code>namespace</code> and <code>__autoload</code></p>
  
  <p>I also tried <code>spl_autoload_register</code> but did not success. Kindly suggest.</p>
  
  <p><strong>EDIT:1</strong></p>
  
  <p>Also, if i want to replace it with spl_autoload_register how that can be implemented.</p>