Shorthand Operators summary table : Arithmetic Operators « Operator « PHP






Shorthand Operators summary table



Operation       Operator        Example        Expansion

Assignment      =               $a = 5         $a = 5

Addition        +=              $a += 5        $a = $a + 5

Subtraction     -=              $a -= 5        $a = $a - 5

Multiplication  *=              $a *= 5        $a = $a * 5

Division        /=              $a /= 5        $a = $a / 5

Concatenation   .=              $a .= "Add"    $a = $a . "Add"

Modulus         %=              $a %= 5        $a = $a % 5

Bitwise AND     &=              $a &= 5        $a = $a & 5

Bitwise         |=              $a |= 5        $a = $a | 5
inclusive OR

Bitwise         ^=              $a ^= 5        $a = $a ^ 5
exclusive OR (XOR)

Bitwise NOT     ~=              $a ~= 5        $a = $a ~ 5

Bitwise         <<=             $a <<= 5       $a = $a << 5
left-shift

Bitwise         >>=             $a >>= 5       $a = $a >> 5 
right-shift


           
       








Related examples in the same category

1.Arithmetic Operators
2.Arithmetical Operators
3.An example of PHP's automatic type conversion is the addition operator '+'.
4.Changing the default precedence using parentheses
5.Increment/decrement Operators
6.Incrementing and decrementing
7.Using the autodecrement operator
8.Using the negation operator
9.Using pre- and postincrement
10.Using autoincrement to add to a variable
11.Postfix and Prefix Operators summary table
12.Peculiarities of the ++ and -- Operators
13.postfix and prefix increment operators also work on letter values
14.Postfix and Prefix Operators in Action
15.Calculation Results for Postfix and Prefix Operators
16.Variables Are Assigned by Value
17.Using Assignment Operators