O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.4. User Defined Functions

These functions support using and creating your own functions.

value call_user_func(string function, …)

Use call_user_func (Listing 11.78) to execute a function you've defined. The function argument names the function. Arguments to be passed to the function follow. This allows you to determine the function you wish to call at runtime.

You may use this function to call a method on a class or object by passing an array for the function name. The first element of the array should be the name of the class or the object. The second element should be the method name.

Listing 11.78. call_user_func
 <?php function addThree($a, $b, $c) { return($a + $b + $c); } function multiplyThree($a, $b, $c) { return($a + $b + $c); } class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required