nerdexam
Zend

200-550 · Question #22

What is the output of the following code? class C { public $x = 1; function __construct() { ++$this->x; } function __invoke() { return ++$this->x; } function __toString() { return (string)…

The correct answer is D. 3. See the full explanation below for the reasoning.

Question

What is the output of the following code? class C { public $x = 1; function __construct() { ++$this->x; } function __invoke() { return ++$this->x; } function __toString() { return (string) --$this->x; } } $obj = new C(); echo $obj();

Options

  • A0
  • B1
  • C2
  • D3

How the community answered

(53 responses)
  • A
    4% (2)
  • B
    15% (8)
  • C
    9% (5)
  • D
    72% (38)

Community Discussion

No community discussion yet for this question.

Full 200-550 Practice