1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which keyword precedes a method name?

Added 22 Jan 2024

Which keyword precedes a method name?

  1. method
  2. function Correct answer
  3. public
  4. protected

Correct answer

B. function

14 views

MCQSEXAM

Explanation

In PHP a method is declared with the function keyword placed immediately before the method name, for example public function getPrice().

Visibility keywords such as public or protected may come earlier in the declaration, but it is function that directly precedes the name. There is no method keyword in PHP.

Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs