What is the output of the following code?

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 = function($x) {

return $x*$x;

};

$m = $a->mul();

echo $m(3);
A . 9
B . 6
C . 0
D . 3

Answer: B

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments