I have string c开发者_如何学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);
http://php.net/reflection
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.
精彩评论