Bird
0
0

What is the output of this PHP code?

medium📝 Predict Output Q4 of 15
PHP - Operators
What is the output of this PHP code?
$a = 7;
$a += 3;
$a *= 2;
echo $a;
A20
B14
C10
D16
Step-by-Step Solution
Solution:
  1. Step 1: Calculate after addition

    Initially, $a = 7. After $a += 3;, $a becomes 10.
  2. Step 2: Calculate after multiplication

    Then $a *= 2; multiplies $a by 2, so $a becomes 20.
  3. Final Answer:

    20 -> Option A
  4. Quick Check:

    Compound assignments update $a stepwise = 20 [OK]
Quick Trick: Apply compound assignments step-by-step [OK]
Common Mistakes:
  • Multiplying before adding
  • Confusing += and *= effects
  • Forgetting to update variable after each step

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes