2

I would like something like this but dynamically from an array like this:

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

So class would be called like this:

$class = new class("first","second","third");
Manse
  • 37,343
  • 10
  • 82
  • 108

1 Answers1

3

You can use reflection for it:

$refClass = new ReflectionClass('SomeClass');
$instance = $refClass->newInstanceArgs($args);
ThiefMaster
  • 298,938
  • 77
  • 579
  • 623