PrepAway - Latest Free Exam Questions & Answers

What is the error in the following declaration of a static class method?

What is the error in the following declaration of a static class method?
<code>
1 <?php
2 class car {
3 static $speeds = array(
4 ‘fast’,
5 ‘slow’,
6 ‘medium’,
7 );
8
9 static function getSpeeds()
10 {
11 return $this->speeds;
12 }
13 }
14 ?>
</code>

PrepAway - Latest Free Exam Questions & Answers

A.
Static methods must not return a value.

B.
The use of $this from within static methods is not possible.

C.
Static methods need the method keyword instead of the function keyword.

D.
There is no static keyword in PHP.

One Comment on “What is the error in the following declaration of a static class method?


Leave a Reply

Your email address will not be published. Required fields are marked *