Zend
200-710 · Question #109
What is the output of the following code? ``php class A { public $a = 1; public function __construct($a) { $this->a = $a; } public function mul() { return function ($x) { return $this->a*$x; }; } } $a
The correct answer is B. 6. See the full explanation below for the reasoning.
Question
What is the output of the following code?
class A {
public $a = 1;
public function __construct($a) { $this->a = $a; }
public function mul() {
return function ($x) {
return $this->a*$x;
};
}
}
$a = new A(2);
$a_mul = $a->mul();
$m = $a->mul();
echo $m(3);
Options
- A9
- B6
- C0
- D3
How the community answered
(24 responses)- A4% (1)
- B79% (19)
- C13% (3)
- D4% (1)
Community Discussion
No community discussion yet for this question.