0

Basically I'm trying to do this

$className = 'myClass';

$className::myMethod($aParameter);

but I'm getting a unexpected T_PAAMAYIM_NEKUDOTAYIM, however I read that I could replycate

$className::myMethod();

with

call_user_func(array($className, 'myMethod'));

the only problem now is that I really need to pass that paremeter, any idea on how can I get around this?

1 Answer 1

3

Just add the parameter. call_user_func() accepts an unlimited additional parameters that it will pass on to the called function.

call_user_func(array($className, 'myMethod'), $aParameter);
Sign up to request clarification or add additional context in comments.

1 Comment

I see! I was getting really confused regarding the parameter on class_user_func, i was indeed passing the parameter in the array().

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.