PHP Operators are used to perform operations on variables and values. Operators are the symbols that tells the PHP processor to perform certain action. PHP divides the operators in the following categories:
S.No | Operator Category | Operator Symbols | Operator Name |
---|---|---|---|
Arithmetic Operators | + - * / % ** | Addition Subtraction Multiplication Division Modulas Exponentiation | |
Assignment operators | = += -= *= /= | Assignment Operator Addition Assignment Subtraction Assignment Multiplication Assignment Divide Assignment | |
Relational/Comparison operators | > < >= <= !=, <> == === | Greater than Less than Greater than equals to Less than equals to Not equals to Equal, Equals to Strictly equal | |
Logical operators | && , and || , or ! , not xor | And Or Not Exclusive Or | |
Increment/Decrement operators | $a++ ++$a $a-- --$a | Post Increment Pre Increment Post Decrement Pre Decrement | |
String operators | . .= | Concatenation Concatenation assignment | |
Conditional Operator | ? : | Ternary Operator |
Category | Operator | Associativity |
---|---|---|
Unary | ! ++ -- | Right to left |
Multiplicative | * / % | Left to right |
Additive | + - | Left to right |
Relational | < <= > >= | Left to right |
Equality | == != | Left to right |
Logical AND | && | Left to right |
Logical OR | || | Left to right |
Conditional | ? : | Right to left |
Assignment | = , += , -= , *= , /= , %= | Right to left |