Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q5 of 15
PHP - Functions
What will be the output of this PHP code?
function multiply($a, $b) {
  return $a * $b;
}
echo multiply(3, 4);
A7
BError: Missing argument
C12
D34
Step-by-Step Solution
Solution:
  1. Step 1: Understand function behavior

    The multiply function returns the product of $a and $b.
  2. Step 2: Calculate output

    Calling multiply(3, 4) returns 3 * 4 = 12.
  3. Final Answer:

    12 -> Option C
  4. Quick Check:

    Multiplication of arguments = 12 [OK]
Quick Trick: Arguments replace parameters in function calls [OK]
Common Mistakes:
  • Adding instead of multiplying
  • Concatenating numbers as strings
  • Expecting error without default values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes