call($function, $arguments = array())

Calls a function with a given set of arguments

  • $function (callable)
  • $arguments (mixed)
    One argument or array of arguments

Example

Without function arguments

call('foo'); // Equivalent to foo()
call(array($foo, 'bar')); // Equivalent to $foo->bar()

With one function argument

call('foo', 'bar'); // Equivalent to foo('bar')
call(array($foo, 'bar'), 'baz'); // Equivalent to $foo->bar('baz')

With more than one function argument

call('foo', array('bar', 'baz')); // Equivalent to foo('bar', 'baz')
call(array($foo, 'bar'), array('baz', 'foobar')); // Equivalent to $foo->bar('baz', 'foobar')