ReflectionClass::newInstanceArgs
从给出的参数创建一个新的类实例
&reftitle.description;
public objectnullReflectionClass::newInstanceArgs
arrayargs[]
创建一个类的新实例,给出的参数将传递到类的构造函数。
&reftitle.parameters;
args
这个参数以 array 形式传递到类的构造函数。
&reftitle.returnvalues;
返回类的新实例,失败时返回 &null;。
&reftitle.errors;
如果类的构造函数不是 public 的将导致产生 ReflectionException。
当 args 指定了一个或多个参数,而类不具有构造函数时,将导致 ReflectionException。
&reftitle.examples;
ReflectionClass::newInstanceArgs 的基本用法
newInstanceArgs(array('substr'));
var_dump($instance);
?>
]]>
&example.outputs;
string(6) "substr"
}
]]>
&reftitle.seealso;
ReflectionClass::newInstance
ReflectionClass::newInstanceWithoutConstructor