<<< Previous question <<< Question ID#0087.md >>> Next question >>>
You want to create an anonymous function in the middle of a script that will return the square of a given number. Which of the following PHP scripts can you use to accomplish the task?
Each correct answer represents a complete solution. (Choose two)
- A)
$foo = create_function('$x', 'return $x*$x;'); echo $foo(10);
- B)
$foo = create_function("\$x", "return \$x*\$x;"); echo $foo(10);
- C)
$foo = create_function("$x", "return $x*$x;"); echo $foo(10);
- D)
$foo = create_function("$x", "$x*$x;"); echo $foo(10);
Answer
Answer: A, B