Bird
0
0

What will this PHP code output?

medium📝 Predict Output Q5 of 15
PHP - Functions
What will this PHP code output?
function add($a, $b) {
  return $a + $b;
}
echo add(3, 4);
A7
B34
Cadd(3, 4)
DError: missing semicolon
Step-by-Step Solution
Solution:
  1. Step 1: Understand function parameters and return

    The function adds two numbers and returns the sum.
  2. Step 2: Calculate the sum of 3 and 4

    3 + 4 equals 7, so the function returns 7.
  3. Final Answer:

    7 -> Option A
  4. Quick Check:

    Function returns sum = 7 [OK]
Quick Trick: Return adds values, echo prints result [OK]
Common Mistakes:
  • Concatenating numbers as strings
  • Forgetting to return value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes