1

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.)

1 Answer 1

6

Maybe the reflection API is the best shot here.

$class = new ReflectionClass('className');
$instance = $class->newInstanceArgs($argsArray);
Sign up to request clarification or add additional context in comments.

1 Comment

+1 for relection, call_user_func_array seems to have bug when calling referenced arguments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.