Bird
0
0

Which of the following is the correct syntax to declare a function named hello with no parameters in PHP?

easy📝 Syntax Q3 of 15
PHP - Functions
Which of the following is the correct syntax to declare a function named hello with no parameters in PHP?
Afunction hello[] {}
Bfunction hello {}
Cdef hello() {}
Dfunction hello() {}
Step-by-Step Solution
Solution:
  1. Step 1: Check PHP function syntax

    Functions require parentheses after the name, even if no parameters exist.
  2. Step 2: Validate each option

    function hello() {} uses correct syntax: 'function hello() {}'. Others miss parentheses or use wrong keywords.
  3. Final Answer:

    function hello() {} -> Option D
  4. Quick Check:

    Function syntax = function name() {} [OK]
Quick Trick: Always use parentheses after function name [OK]
Common Mistakes:
  • Omitting parentheses
  • Using wrong keywords like def
  • Using square brackets instead of parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes