2

我想要这样的东西,但动态地从这样的数组中获取:

$array = array("first","second","third");

所以类会这样调用:

$class = new class("first","second","third");
4

1 回答 1

3

您可以为此使用反射:

$refClass = new ReflectionClass('SomeClass');
$instance = $refClass->newInstanceArgs($args);
于 2012-04-20T17:07:35.190 回答