PHP使用变量声明类

Im trying to execute the following code

$our_controller = new App\Controllers\$routing->_new['controller']();

But Im getting 'Unexpected $routing'

And this is the class Im trying to load looks like

namespace App\Controllers;

class HomeController extends BaseController
{
      public function __construct()
      {
          parent::__construct();
      }
}

If I type the following

$our_controller = new App\Controllers\HomeController();

Works perfectly but I must use the variable instead of HomeController

Try this, I think it should work:

$namespace = 'App\Controllers\' . $routing->_new['controller']();

$our_controller = new $namespace;