Create an object by passing arguments on the similarity of call_user_func_array

In the function that you can pass unlimited number of arguments, I can get them all as an array using func_get_args. At the same time, I can call another function with the same arguments with call_user_func_array.

But I want to create an object by passing its constructor the arguments received in the parent function, using func_get_args. Any idea how to do it?

October 8th 19 at 03:36
3 answers
October 8th 19 at 03:38

Although I would certainly think not whether to pass the array as a single parameter and not to pile up.
The fact that you need to create objects of classes not only her, but also strangers, which can be written in different ways.
Thanks for the link, seems something that should have - Trenton.Cri commented on October 8th 19 at 03:41
October 8th 19 at 03:40
And his method ReflectionClass newInstanceArgs should help.
Thank you - Trenton.Cri commented on October 8th 19 at 03:43
October 8th 19 at 03:42
What does the parent function? Can the constructor of the parent class? Just a strange way to talk about functions in terms of inheritance.

Find more questions by tags OOPPHP