class Horse {
public function __construct( $a, $b, $c ) {
echo $a;
echo $b;
echo $c;
}
}
$myClass = "Horse";
$refl = new ReflectionClass($myClass);
$instance = $refl->newInstanceArgs( array(
"first", "second", "third"
));
//"firstsecondthird" is echoed
You can also inspect the constructor in the above code:
$constructorRefl = $refl->getMethod( "__construct");
print_r( $constructorRefl->getParameters() );
/*
Array
(
[0] => ReflectionParameter Object
(
[name] => a
)
[1] => ReflectionParameter Object
(
[name] => b
)
[2] => ReflectionParameter Object
(
[name] => c
)
)
*/