Bird
0
0

What is the output of the following PHP code?

medium📝 Predict Output Q4 of 15
PHP - Operators
What is the output of the following PHP code?
$a = 2 + 3 * 4 - 5 / 5;
A10
B11
C13
D14
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate multiplication and division first

    3 * 4 = 12 and 5 / 5 = 1.
  2. Step 2: Evaluate addition and subtraction left to right

    2 + 12 = 14, then 14 - 1 = 13.
  3. Final Answer:

    13 -> Option C
  4. Quick Check:

    Operator precedence = 13 [OK]
Quick Trick: Multiply/divide before add/subtract [OK]
Common Mistakes:
  • Adding before multiplying
  • Ignoring division
  • Calculating subtraction first

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes