nerdexam
National_Instruments

200-500 · Question #151

What is the output of the following script? 1 <?php 2 class a 3 { 4 public $val = 10; 5 } 7 function renderVal (a $a) 8 { 9 return $a->$val; 10 } 12 renderVal (new a); 13 ?>

The correct answer is C. A fatal error. See the full explanation below for the reasoning.

Question

What is the output of the following script? 1 <?php 2 class a 3 { 4 public $val = 10; 5 } 7 function renderVal (a $a) 8 { 9 return $a->$val; 10 } 12 renderVal (new a); 13 ?>

Options

  • ANothing
  • BNULL
  • CA fatal error
  • D$val
  • E10

How the community answered

(18 responses)
  • B
    6% (1)
  • C
    78% (14)
  • D
    11% (2)
  • E
    6% (1)

Community Discussion

No community discussion yet for this question.

Full 200-500 Practice