From the Wrox book "Professional PHP Programming" :
<snip!>
"PHP allows variables to refer to functions. This can be useful when dynamic conditions will determine which function should be called in a specific situation. When a variable refers to a function, the function can be invoked by placing praentheses containing the arguments (if any) after the variable name.
"In the following example, we do not know in advance which function should be called to load the page (assuming that the URL for the page has already been assigned to $URL), so we test the value of another variable ($browser_type) and assign the appropriate function to $loading_function.
switch ($browser_type) {
case "NN": // Netscape Navigator
$loading_function = "load_nn";
break;
case "IE": // Internet Explorer
$loading_function = "load_ie";
break;
default: // All others
$loading_function = "load_generic";
}
// Now call the appropriate loading function:
$loading_function($URL);
<snip!>
Good book, highly recommended!
-- Rich Rijnders
-- Irvine, CA US