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)- A4% (2)
- B15% (8)
- C9% (5)
- D72% (38)
Community Discussion
No community discussion yet for this question.