Bird
0
0

Identify the error in this PHP function code:

medium📝 Debug Q14 of 15
PHP - Functions
Identify the error in this PHP function code:
function sayHi {
  echo "Hi!";
}
AMissing semicolon after function keyword
BMissing parentheses after function name
CFunction name cannot be sayHi
DEcho statement is incorrect
Step-by-Step Solution
Solution:
  1. Step 1: Check function declaration syntax

    In PHP, function names must be followed by parentheses, even if empty.
  2. Step 2: Identify the missing part

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

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

    Function declaration needs () [OK]
Quick Trick: Always add () after function name [OK]
Common Mistakes:
  • Forgetting parentheses in function declaration
  • Adding semicolon after function keyword
  • Thinking function names are restricted

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes