+----Phpstar-------------------------------------+ +---to provide you with the most complete PHP learning notes--+ +----Read notes can learn PHP-------------------- + +-----------------------------------------------------+ variable functions are similar to variable variables, and the names of functions on functions are also variable. means that the function name of the function can also be substituted with a variable. Using variable variables Complete calculator anonymous function: Anonymous function, refers to a function without the name of the function. So this function has no way to be invoked like a normal function. Typically is used as a parameter to a function, which makes it automatically invoked. callback data pseudo type. For example: Map array operations: We have no way to call this anonymous function directly, so it is always used as a parameter to a function. The function of an anonymous function: A normal function can be used first, then defined. Because the declaration of a function is not determined during the execution of the script, it is determined during the compilation of the script. and compilation before execution. In contrast, anonymous functions are determined at execution time. and normal function once declared can be invoked before the end of the script. In this respect, the function space is released immediately after the anonymous function has finished executing. Anonymous functions can only be executed once. If a function is used only once, the anonymous function is more resource efficient. But anonymous functions are a sexual feature of PHP. Php5.3 will have anonymous functions. If there are no anonymous functions, what should be done with calls that need to be callback in the form of arguments? The callback parameter should be replaced with a function name and the corresponding function must exist. tip:php anonymous function also known as closure function. Recursive invocation of the function: A function can be invoked anywhere, even in the function's body, to invoke the current function. If a function calls itself, call it a recursive call to a function. The most extreme example: the recursive invocation of the function can solve the display of some of the problems in life that can think of in terms of recursive thinking. Find factorial 5! = 5 * 4&NBsp;* 3 * 2 * 1; 4! = 4 * 3 * 2 * 1 3! = 3 * 2 * 1; 1! = 1; 5! = 5 * 4!; 4! = 4 * 3!; Suppose we now define a function that can find the factorial of N. jiecheng (n); returns the factorial of n n * jiecheng (n-1) jiecheng (5) = 5 * Jiecheng (4); If you need to use recursive thinking to complete the programming design, you need to consider 2 major issues? 1 recursion point? Why this problem can be accomplished using recursion. 2 , a recursive exit? If you call yourself without restriction within a function, you are bound to execute it indefinitely (dead). Be sure to find that recursive calls can be terminated when a condition is reached. This condition is the recursive point. For example factorial: recursive point: Jiecheng (n) = n * jiecheng (n-1). The solution to the factorial and n-1 of N is the same, so you can do it with a function. Export: When you need to get the factorial of 1, you don't have to continue to call yourself, because 1 factorial is known. Whenever a call to a function will be in the function's stack area form the execution space of a function: stack: Memory of a storage area. His operating characteristics: LIFO (Advanced out) Note: Recursively called functions, each will open up a memory space, meaning that a call has a separate scope, so Local variables are not shared. usually use static static local variables to solve the problem. Fibonacci Series: The first two are known (usually 1, 1), starting with the third, each of which is the sum of the first two: 1 1 2 3 5 8 13 write a function, find the value of the Fibonacci sequence N term fbnq (4) == 3 Fbnq (7) == 13 FBNQ (n) = fbnq (n-1) + fbnq (n-2) ; Recursive point: Recursive exit: The system function of some relevant information of the first two known functions. Function_exists (' function name '); determine whether a function is defined, and whether it already exists. The return value is a Boolean type Func_get_args (); Gets the value of all the parameters of the current function. It should be called within the function, getting the arguments passed in when the function is called, not the formal parameters when the function is defined. Note: When a function is invoked, the number of actual arguments should be greater than or equal to the number of formal arguments. Only more not less! When the number of actual parameters The number of redundant form parameters How do we get the value of the actual parameter in the function? You can use the func_get_args () function within the function to get all the actual parameters. The actual parameters are saved in the return result of Func_get_args (), in the location of the pass. For example: Make a function to get the and all parameters. The requirement is that the number of parameters is not fixed. SumAll (); 0 SumAll (a); 10 SumAll (10, 20); 30 SumAll (10,  20, 30) 60 procedures are as follows: Func_get_arg (Int index) Get a function of a parameter. The ordinal number of the int represented by the parameter. The index position starts at 0. func_num_args Gets the number of actual parameters. function You can use the magic constant __function__ to replace the current function name. Common usage, in recursion Use this value: you can ensure that when the function name changes, do not need to modify the function body, you can complete the operation.