Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 775 Bytes

0087.md

File metadata and controls

34 lines (26 loc) · 775 Bytes

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