Operators

Assignment

$a = $b Assign
$a += $b $a = $a + $b Addition
$a -= $b $a = $a - $b Subtraction
$a *= $b $a = $a * $b Multiplication
$a /= $b $a = $a / $b Division
$a %= $b $a = $a % $b Modulus

 

Increment / Decrement

++$a Pre-Increment Increments $a by one, then returns $a
$a++ Post-Increment Returns $a, then Increments $a by one
--$a Pre-Decrement Decrements $a by one, then returns $a
$a-- Post-Decrement Returns $a, then Decrements $a by one

 

Arithmetic

$a + $b Addition Sum of $a and $b
$a - $b Subtraction Difference of $a and $b
$a * $b Multiplication Product of $a and $b
$a / $b Division Quotient of $a and $b
$a % $b Modulus Remainder of $a divided by $b

 

String

$a . $b Concatenate Produce single string, with contents of $a, followed by contents of $b
$a .= "string" Concatenating Assignment Concatenate "string" with $a and reassign to $a

 

Comparison

$a == $b Equal TRUE if $a is equal to $b
$a === $b Identical TRUE is $a is equal to $b, and they are of the same type
$a != $b Not Equal TRUE if $a is not equal to $b
$a <> $b Not Equal TRUE if $a is not equal to $b
$a !== $b Not Identical TRUE if $a is not equal to $b, or they are not of the same type
$a < $b Less Than TRUE if $a is strictly less than $b
$a > $b Greater Than TRUE if $a is strictly greater than $b
$a <= $b Less Than or Equal To TRUE if $a is less than or equal to $b
$a >= $b Less Than or Equal To TRUE if $a is greater than or equal to $b

 

Logical

$a and $b And TRUE if both $a and $b are TRUE
$a && $b And TRUE if both $a and $b are TRUE
$a or $b Or TRUE if either $a or $b is TRUE
$a || $b Or TRUE if either $a or $b is TRUE
$a xor $b Xor TRUE if either $a or $b is TRUE, but not both
! $a Not TRUE if $a is not TRUE

Leave a Reply