I have string containing classname and an array of args.
$classname($args) works, but in this case I have only 1 argument in constructor
Anyone know, how to do this with args expanded?
$reflection = new ReflectionClass($classname);
$object = $reflection->newInstanceArgs($args);
Haha I just asked this question: PHP passing a class as a reference?
And you can't expand the $args
. You could try passing $args[0], $args[1]
etc.