1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which one of the following is the right way of defining a…

Added 19 Jan 2024

Which one of the following is the right way of defining a function in PHP?

  1. function { function body }
  2. data type functionName(parameters) { function body }
  3. functionName(parameters) { function body }
  4. function fumctionName(parameters) { function body } Correct answer

Correct answer

D. function fumctionName(parameters) { function body }

12 views

MCQSEXAM

Explanation

A PHP function is declared with the function keyword, followed by the function name, a parameter list in parentheses and the body in curly braces: function functionName(parameters) { ... }.

Unlike C or Java, PHP does not put a return data type before the function name, and the function keyword cannot be omitted, which rules out the other options.

Keep preparing with more Computer Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is D? 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