Anonymous functions, also called closures, allow you to temporarily create a function without a specified name. The value most commonly used as a callback function argument. Of course, there are other applications as well.
Implementation structure
## Closure: Put the anonymous function in a normal function, or you can return the anonymous function, which forms a simple closure
Keywords: use connects the variables and values of the context
Application scenarios of closures:
①, to protect the safety of variables within the function. The variables in the outer function can only be accessed by the inner function, and cannot be accessed through other means②. The variables in the outer function always exist in the memory, so they will be used every time it is executed.The above is the detailed content of anonymous function. For more information, please follow other related articles on the PHP Chinese website!