An anonymous function can temporarily create a function that has no name and is commonly used as the value of a callback function parameter
<?php$test = function ($a) {echo "Hello,". $a;}; $test ("World"); >
Be sure to add a semicolon at the end of the anonymous function
Execution results
The callback function makes an anonymous function argument
<?phpfunction callback ($a) {$a ();} Callback (function () {//declares an anonymous function and passes it to the callback () function echo "Test";});? >
Execution results
referencing external variables
<?phpfunction callback ($a) {$a ();} $str = "PHP"; callback (function () use ($STR) {//The external variable is referenced by using keyword echo $str. "Test";});? >
Use refers to a copy of an external variable to be fully referenced, preceded by a &
Callback (function () use (& $str) {});
php function (vi)-anonymous function (closure function)