I am trying to instantiate an object from a class, substituting an element from an array as the classname, but I keep getting PHP parse errors.
I am thinking the \
character is somehow escaping the $
of the array varaiable?
i.e.
$this->controller = new \app\controllers\$exploded_url[0];
gives
Parse error: syntax error, unexpected '$', expecting identifier (T_STRING)
$this->controller = new \app\controllers\${exploded_url[0]};
gives
Parse error: syntax error, unexpected '$exploded_url' (T_VARIABLE), expecting identifier (T_STRING)
How can I fix this parse error?