A mutable function, which is called by the value of a variable, because the value of the variable is variable, so you can invoke different functions by changing the value of a variable .
Often used in callback functions, function lists, or depending on dynamic parameters to invoke different functions. The variable function is called by the variable name in parentheses.
A mutable function can also be used on an object's method call:
Here: Theobject member access symbol
When we create custom functions and understand the use of mutable functions, in order to ensure that the functions called by the program are present, we often use function_exists to determine whether a function exists. The same method_exists can be used to detect whether a class's methods exist.
class defines whether the class_exists can be used.
Parameters of the function
The argument list allows you to pass information to a function, which is a comma-delimited list of expressions. Parameters are evaluated from left to right.
PHP supports passing parameters by value (default), passing parameters by reference, and default parameters. Variable-length parameter lists are also supported.
By default, a function parameter is passed by value ( so that it does not change the value outside the function even if the value of the parameter is changed inside the function ). if you want to allow a function to modify its parameter values, you must pass the arguments by reference .
If you want a parameter of a function to always be passed by reference, you can precede the argument with a symbolic & in the function definition:
Pass by value:
Reference delivery:
The value of the default parameter
Output:
PHP Learning (functions)