Bird
0
0

Which of the following is the correct syntax to subtract 4 from variable $num and update it?

easy📝 Syntax Q3 of 15
PHP - Operators
Which of the following is the correct syntax to subtract 4 from variable $num and update it?
A$num -= 4;
B$num =- 4;
C$num = -4;
D$num - 4;
Step-by-Step Solution
Solution:
  1. Step 1: Understand compound subtraction syntax

    The correct syntax to subtract and assign is $num -= 4;.
  2. Step 2: Identify incorrect options

    =- is invalid syntax, = -4 assigns negative 4, and $num - 4; does not update the variable.
  3. Final Answer:

    $num -= 4; -> Option A
  4. Quick Check:

    Subtract and assign uses -= operator [OK]
Quick Trick: Use -= to subtract and update variable [OK]
Common Mistakes:
  • Writing =- instead of -=
  • Assigning negative value instead of subtracting
  • Not updating variable with assignment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes