9

I need to use call_user_func . I will need to call a function in a separate file in separate class with 5 arguments . I couldnt find any example here http://php.net/manual/en/function.call-user-func.php . IS there any way to do this ?

1
  • 4
    Of course there is. What have you tried? Did it work? If not, what happened instead? Commented Aug 2, 2012 at 15:14

1 Answer 1

15

Personally I use call_user_func_array.

$result = call_user_func_array(array($objectInstance, 'objectMethod'), array('parameter one', 'parameter two'));

If the method is a static one, replace $objectInstance with the name of the class being used. You can also use stand-alone functions too:

$result = call_user_func_array('functionName', array('parameter one', 'parameter two'));

Hope this makes sense? :]

However in the future, try and show us what you have and haven't done :]

Sign up to request clarification or add additional context in comments.

1 Comment

call_user_func_array is the best! :)

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.