nerdexam
National_Instruments

200-500 · Question #9

What is the output of the following code? <code> class test { public $value = 0; function test() { $this->value = 1; } function __construct() { $this->value = 2; }} $object = new test(); echo…

The correct answer is A. 2. See the full explanation below for the reasoning.

Question

What is the output of the following code? <code> class test { public $value = 0; function test() { $this->value = 1; } function __construct() { $this->value = 2; }} $object = new test(); echo $object->value;

Options

  • A2
  • B1
  • C0
  • D3
  • ENo Output, PHP will generate an error message.

How the community answered

(17 responses)
  • A
    76% (13)
  • B
    6% (1)
  • D
    12% (2)
  • E
    6% (1)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice