Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Chapter 6 shows you how to pass a customized sort function into a predefined sorting function. The ability to do so, in your own library functions, is a powerful tool. This section will demonstrate how you pass a function name to make a dynamic function call.
The mechanism to make dynamic function calls is tied to how variables are managed in PHP. You can define a function in your page, or library, and then pass the name of the function as a string and its parameters as a list to another function. Inside the function, you append parentheses containing the actual parameter list to the variable that contains the function name. This statement makes a dynamic function call to the function represented by the string and uses a parameter list that can contain static values, variables, or an array of values.