Bird
0
0

Identify the error in this PHP function declaration:

medium📝 Debug Q6 of 15
PHP - Functions
Identify the error in this PHP function declaration:
function sayHi {
    echo "Hi!";
}
AFunction name is invalid
BMissing parentheses after function name
CMissing semicolon after function keyword
DMissing curly braces
Step-by-Step Solution
Solution:
  1. Step 1: Check function declaration syntax

    Functions must have parentheses after the name, even if empty.
  2. Step 2: Identify the missing part

    The code misses parentheses after sayHi, causing syntax error.
  3. Final Answer:

    Missing parentheses after function name -> Option B
  4. Quick Check:

    Function syntax requires parentheses [OK]
Quick Trick: Always add () after function name [OK]
Common Mistakes:
  • Omitting parentheses
  • Adding semicolon after function keyword
  • Misplacing curly braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes