Is there a call_user_func() equivalent to create a new class instance?
How can I create a class with a given array of arguments to be sent to the constructor? Something along the lines of: class a { var $args = false; function a() {$this->args = func_get_args();} } $a = call_user_func_array('new a',array(1,2,3)); print_r($a->args); Ideally this needs to work, without modification to the class, in both PHP4 and PHP5. Any ideas? ReflectionClass:newInstance() (or newInstanceArgs()) let's you do that. e.g. class Foo { public function __construct() { $p = func_get_args(); echo 'Foo::__construct(', join(',', $p), ') invoked'; } } $rc = new ReflectionClass('Foo'); $foo