Bird
0
0

What is wrong with this PHP code?

medium📝 Debug Q7 of 15
PHP - Functions
What is wrong with this PHP code?
function sayHello() {
  echo "Hello";
}
sayhello();
AFunction names are case-sensitive, so sayhello() is undefined
BMissing semicolon after function call
CFunction cannot use echo inside
DNo error, code runs fine
Step-by-Step Solution
Solution:
  1. Step 1: Check PHP function name rules

    PHP function names are case-insensitive.
  2. Step 2: Verify the function call

    The function is defined as sayHello() but called as sayhello(), which works because of case-insensitivity, so no error.
  3. Final Answer:

    No error, code runs fine -> Option D
  4. Quick Check:

    PHP functions case-insensitive = A [OK]
Quick Trick: PHP function names are case-insensitive [OK]
Common Mistakes:
  • Thinking function names are case-sensitive
  • Forgetting semicolon after call

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes