Php call_user_func with class and arguments

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

+5
source share
1 answer

Personally, I use call_user_func_array.

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

If the method is static, replace $objectInstancewith the name of the class you are using. You can also use standalone functions:

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

Hope this makes sense ?:]

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

+10
source

All Articles