I want to use variables inside class names.
For example, let's set a variable named $var
to "index2".
Now I want to print index2
inside a class name like this:
controller_index2
, but instead of doing it manually, I can just print the var name there like this:
controller_$var;
but I assume that's a syntax error.
How can I do this?
function __construct()
{
$this->_section = self::path();
new Controller_{$this->_section};
}