T
T
Terion2012-02-11 20:40:45
PHP
Terion, 2012-02-11 20:40:45

Creating an object with passing arguments like call_user_func_array

In a function that can be passed an unlimited number of arguments, I can get them all as an array using func_get_args . However, I can call another function with the same arguments using call_user_func_array .

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

Thank you

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max, 2012-02-11
@Terion

stackoverflow.com/questions/3395914/pass-arguments-from-array-in-php-to-constructor
Although, of course, I would think if it's worth passing the array as one parameter and not piling it up.

D
deadkrolik, 2012-02-11
@deadkrolik

ReflectionClass and its newInstanceArgs method should help.

A
Alexey Sundukov, 2012-02-11
@alekciy

What does parent function mean? Maybe a parent class constructor? It's just kind of weird to talk about a function in terms of inheritance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question