title: PHP Dynamic Class Loading w/ Namespaces
body: <p>I'm using namespaces in PHP, and trying to load classes dynamically. My currently structure looks like this:</p>
  
  <pre><code> class Bootstrap {
  
      protected $controller = 'home';
  
      protected $method = 'index';
  
      protected $params = [];
  
      function __construct($url) {
          $urlArray = $this-&gt;parseurl($url);
          if(file_exists('../app/http/controllers/' . $urlArray[0] . '.php'))
          {
              $this-&gt;controller = $urlArray[0];
              unset($urlArray[0]);
          }
  
          require_once '../app/http/controllers/' .  $this-&gt;controller . '.php';
  
          $this-&gt;controller = new Controllers\$this-&gt;controller;  
  
          var_dump($this-&gt;controller);
      }
      public function parseurl($url) {
          return $url = explode('/', filter_var(rtrim($url, '/'), FILTER_SANITIZE_URL));
      }
  }
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <p>Parse error: syntax error, unexpected '$this' (T_VARIABLE), expecting identifier (T_STRING)</p>
  
  <p>How do I make it so I can load the classes with this bootstrap function?</p>