I have a question regarding the initialization of the dynamic class, let me explain what I mean:
$class = 'User';
$user = new $class();
$user = new User();
So ... this is not a problem, but I am having problems with the same call when calling a static variable from a class, for example:
$class = 'User';
print $class::$name;
It produces the following error:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in
The course that I tested while completing did not pass print User::$name;, and it works. So the class is working.
Why is this so around?
Next question:
Is there any good reason not to use this “dynamic” way to create classes?
source
share