PrepAway - Latest Free Exam Questions & Answers

What is the output of the following code?

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);

PrepAway - Latest Free Exam Questions & Answers

A.
5

B.
10

C.
50

D.
Fatal error

One Comment on “What is the output of the following code?

  1. Max says:

    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);




    0



    0

Leave a Reply

Your email address will not be published. Required fields are marked *