Zend
200-550 · Question #87
What is the output of the following code? class Number { private $v; private static $sv = 10; public function __construct($v) { $this->v = $v; } public function mul() { return static function ($x) {…
The correct answer is C. 50. See the full explanation below for the reasoning.
Question
What is the output of the following code? class Number { private $v; private static $sv = 10; public function __construct($v) { $this->v = $v; } public function mul() { return static function ($x) { return isset($this) ? $this->v*$x : self::$sv*$x; }; } } $one = new Number(1); $two = new Number(2); $double = $two->mul(); $x = Closure::bind($double, null, 'Number'); echo $x(5);
Options
- A5
- B10
- C50
- DFatal error
How the community answered
(33 responses)- A3% (1)
- B9% (3)
- C85% (28)
- D3% (1)
Community Discussion
No community discussion yet for this question.