Zend
200-530 · Question #205
What is the error in the following declaration of a static class method? 1 <?php 2 class car { 3 static $speeds = array( Zend 200-530 Exam 4 'fast', 5 'slow', 6 'medium', 7 ); 9 static function…
The correct answer is B. The use of $this from within static methods is not possible. See the full explanation below for the reasoning.
Question
What is the error in the following declaration of a static class method? 1 <?php 2 class car { 3 static $speeds = array( Zend 200-530 Exam 4 'fast', 5 'slow', 6 'medium', 7 ); 9 static function getSpeeds() 10 { 11 return $this->speeds; 12 } 13 } 14 ?>
Options
- AStatic methods must not return a value.
- BThe use of $this from within static methods is not possible.
- CStatic methods need the method keyword instead of the function keyword.
- DThere is no static keyword in PHP.
How the community answered
(45 responses)- A4% (2)
- B73% (33)
- C7% (3)
- D16% (7)
Community Discussion
No community discussion yet for this question.