Operator | Example | Name | Result |
---|---|---|---|
** | $a ** $b | Exponentiation | Result of raising $a to the $b'th power. |
+ | +$a | Unary + | Convert $a to a number (int or float) |
- | -$a | Unary - | Negation of $a. |
~ | ~ $a | Bitwise Not | Bits that are set in $a are not set, and vice versa. |
(int) | (int)$a | Cast to Int | The value of $a as an int. |
(float) | (float)$a | Cast to Float | The value of $a as a float. |
(string) | (string)$a | Cast to String | The value of $a as a string. |
(bool) | (bool)$a | Cast to a Bool | The value of $a as a bool. |
@ | @$a | Error Control | Any errors caused by the expression are suppressed. |
! | !$a | Logical Not | true if $a is not true. |
* | $a * $b | Multiplication | Product of $a and $b. |
/ | $a / $b | Division | Quotient of $a and $b. |
% | $a % $b | Modulo | Remainder of $a divided by $b. |
+ | $a + $b | Addition | Sum of $a and $b. |
- | $a - $b | Subtraction | Difference of $a and $b. |
. | $a . $b | Concatenation | Concatenation of the two string values. |
[[ | $a [[ $b | Shift Left | Shift the bits of $a $b steps to the left. |
]] | $a ]] $b | Shift Right | Shift the bits of $a $b steps to the right. |
< | $a < $b | Less Than | true if $a is strictly less than $b. |
<= | $a <= $b | Less Than or Equal To | true if $a is less than or equal to $b. |
> | $a > $b | Greater Than | true if $a is strictly greater than $b. |
>= | $a >= $b | Greater Than or Equal To | true if $a is greater than or equal to $b. |
== | $a == $b | EquaL | true if $a is equal to $b. |
!= | $a != $b | Not equal | true if $a is not equal to $b. |
=== | $a === $b | IdenticaL | true if $a is equal to $b, and they are of the same type. |
!== | $a !== $b | Not Identical | true if $a is not equal to $b, or they are not of the same type. |
& | $a & $b | Bitwise And | Bits that are set in both $a and $b are set. |
^ | $a ^ $b | Bitwise Exclusive Or | Bits that are set in $a or $b but not both are set. |
| | $a | $b | Bitwise Or | Bits that are set in either $a or $b are set. |
&& | $a && $b | Logical And | true if both $a and $b are true. |
|| | $a || $b | Or | true if either $a or $b is true. |
?? | $a ?? $b | Null Coalescing | $a if $a is not null or $b if $a is null. |
? : | $a ? $b : $c | Ternary | Value of $b if $a is true, else value of $c. |
The table is in order of precedence with operators of equal precedence grouped using the background color of the rows.