Descriptionstring create_function ( string args, string code)
Creates an anonymous function from the parameters passed, and returns a unique name for it. Usually the args will be passed as a single quote delimited string, and this is also recommended for the code. The reason for using single quoted strings, is to protect the variable names from parsing, otherwise, if you use double quotes there will be a need to escape the variable names, e.g. \$avar.
You can use this function, to (for example) create a function from information gathered at run time:
Or, perhaps to have general handler function that can apply a set of operations to a list of parameters:
Example 2. Making a general processing function with create_function()
and when you run the code above, the output will be:
Example 3. Using anonymous functions as callback functions