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,765
  • 10
  • 83
  • 108
csaba215
  • 23
  • 3

1 Answers1

3

You can use reflection for it:

$refClass = new ReflectionClass('SomeClass');
$instance = $refClass->newInstanceArgs($args);
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636