The title is really explicit, but I am going to give an example:
class Foo
{
public function __construct($param1, $param2) {
echo 'Class name: ' . __CLASS__ . "\n" .
'param1 = ' . $param1 . "\n" .
'param2 = ' . $param2;
}
}
$class_name = 'Foo';
$params =
[
'content1',
'content2'
];
Having this code, how can I create an instance of Foo, using the parameters in $params.
I know I can do
$class = new $class_name($params);
But this would pass the parameters as one array, I would like it to expand the parameters. The following would be the behavior I would like:
$class = new $class_name($param[0], $param[1]);
Thank you!