Bird
0
0

What will be the output of the following PHP code?

medium📝 Predict Output Q13 of 15
PHP - Operators
What will be the output of the following PHP code?
$a = 10;
$a += 5;
$a -= 3;
echo $a;
A10
B12
C8
D15
Step-by-Step Solution
Solution:
  1. Step 1: Calculate after first operation

    Initially, $a = 10. After $a += 5;, $a becomes 10 + 5 = 15.
  2. Step 2: Calculate after second operation

    Then $a -= 3; subtracts 3: 15 - 3 = 12.
  3. Final Answer:

    12 -> Option B
  4. Quick Check:

    10 + 5 - 3 = 12 [OK]
Quick Trick: Perform operations step-by-step from top to bottom [OK]
Common Mistakes:
  • Ignoring the order of operations
  • Adding instead of subtracting in second step
  • Confusing initial value with final

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes