PHP » PYTHON |
login |
register |
about
|
|
Variable functionsPHP supports the concept of variable functions. This means that if a variable name has parentheses appended to it, PHP will look for a function with the same name as whatever the variable evaluates to, and will attempt to execute it. Among other things, this can be used to implement callbacks, function tables, and so forth. Variable functions won't work with language constructs such as echo(), print(), unset(), isset(), empty(), include(), require() and the like. Utilize wrapper functions to make use of any of these constructs as variable functions.
Example #1 Variable function example
<?php
An object method can also be called with the variable functions syntax. Example #2 Variable method example
<?php
See also call_user_func(), variable variables and function_exists(). |
more
Recently updated
more
Most requested
|