I want to use a variable class name in PHP with a prefixed namespace.
Three variants I have tried produce expectation of an identifier error after the last backslash.
(\api\controllers\(new $class()))->{$method}($this->id);
((new \api\controllers\$class()))->{$method}($this->id);
((new \api\controllers\{$class()}))->{$method}($this->id));
How do I make this work?
usecommand available but I am trying to see if this will work. Please clarify the drawbacks to this approach. Since I use an autoloader I have switched order of autloaded directories which eliminates the class name addressing in this fashion need for this in the present script.