更新时间:2023-11-30 12:46:34
从PHP 5.6开始,您现在可以使用新的Argument Unpacking运算符(...)用单行代码来实现.
As of PHP 5.6, you can now achieve this with a single line of code by using the new Argument Unpacking operator (...).
这是一个简单的例子.
$className='Foo';
$args=['arg1','arg2','arg3'];
$newClassInstance=new $className(...$args);
请参见 PHP变长参数列表了解更多信息.