Complete the code to create an anonymous function assigned to $greet.
$greet = [1]() { echo "Hello!"; };
The keyword function is used in PHP to declare an anonymous function.
Complete the code to call the anonymous function stored in $greet.
$greet[1]();To call a function stored in a variable in PHP, use parentheses () after the variable.
Fix the error in the anonymous function syntax.
$sum = function($a, $b) [1] return $a + $b; };
The function body must start with a curly brace { in PHP anonymous functions.
Fill the blank to create an anonymous function that uses a variable from outside its scope.
$multiplier = 3; $multiply = function($number) use [1] { return $number * $multiplier; };
The use keyword is followed by parentheses enclosing variables to import into the anonymous function's scope, then the function body starts with a curly brace.
Fill the two blanks to create and call an anonymous function that returns the square of a number.
$square = function($n) [1] return $n * $n; [2] echo $square(5);
The anonymous function syntax requires parentheses for parameters, curly braces to start and end the function body.