Bird
0
0

Given the PHP expression:

hard📝 Application Q15 of 15
PHP - Operators
Given the PHP expression:
$value = 8 + 2 * (5 - 3) / 2 - 1;

What is the correct value of $value after evaluation?
A9
B10
C8
D11
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate parentheses first

    Calculate (5 - 3) = 2.
  2. Step 2: Apply multiplication and division next

    Calculate 2 * 2 = 4, then 4 / 2 = 2.
  3. Step 3: Perform addition and subtraction left to right

    Calculate 8 + 2 = 10, then 10 - 1 = 9.
  4. Final Answer:

    8 -> Option C
  5. Quick Check:

    Parentheses, then multiply/divide, then add/subtract = 8 [OK]
Quick Trick: Calculate parentheses first, then multiply/divide, then add/subtract [OK]
Common Mistakes:
  • Ignoring parentheses
  • Doing addition before multiplication
  • Dividing before multiplying inside parentheses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes