I'm working on a simple framework, and I'm having a slight problem. I'd like to use call_user_function_array() to pass parameters to a function. That's fine, except the function I want to pass it to is __construct. I can't create an instance of an object with cufa(), and by instantiating an object, and then using cufa to call that instance's __construct(), I run into problems with a broken class because I'm calling the constructor twice (and one time it's called wrong.)
+5
A:
Maybe the reflection API is the best shot here.
$class = new ReflectionClass('className');
$instance = $class->newInstanceArgs($argsArray);
Savageman
2010-05-31 22:30:45
+1 for relection, call_user_func_array seems to have bug when calling referenced arguments.
Sarfraz
2010-05-31 22:32:01