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)- B6% (1)
- C78% (14)
- D11% (2)
- E6% (1)
Community Discussion
No community discussion yet for this question.