Home > Article > Backend Development > Overview of categories of PHP operators_PHP Tutorial
PHP operators 1. Arithmetic operators
PHP arithmetic operators include + (addition), - (subtraction), * (multiplication) ), / (division), % (remainder).
PHP operators 2. Assignment operators
PHP assignment operators include += (add the value on the left plus the value on the right and assign it to the left), -= (The value on the left minus the value on the right is assigned to the left), *= (The value on the left is multiplied by the value on the right and assigned to the left), /= (The value on the left is divided by the value on the right and assigned to the left), % = (Assign the remainder of the value on the left to the value on the right to the left), .= (Connect the string on the left to the right and assign it to the left).
PHP Operator 3. String Operator
The PHP string operator only has the connection symbol ".", which connects two strings.
PHP operators 4. Increment and decrement operators
PHP increment and decrement operators have four forms: $a++; ++$a; $ a--; --$a.
PHP operators 5. Logical operators
PHP logical operators include! (logical NOT), and (logical AND), && (logical AND), or (logical OR, as long as one of the two expressions is true, the result is true), || (logical OR), xor (XOR, if only one of the two expressions is true, the result is true).
and || have higher priority than and and or.
PHP Operators 6. Bit Operators
Bit operators convert all numbers into binary numbers for calculation.
Bitwise operators include & (bitwise AND), | (bitwise OR), ^ (bitwise XOR), << (bitwise left shift), >> (bitwise Right shift), ~ (bitwise negation).
PHP Operator 7. Relational Operators
Relational operators include == (equal), != (not equal), < (less than), > ; (greater than), <= (less than or equal to), >= (greater than or equal to).
PHP operator 8. Other operators
PHP operator There are also some operators, such as $ (variable symbol), & (variable pointer, take address) , @ (added before the function, no error message is displayed), ?: (ternary operator),, (comma operator), -> (object methods and properties), => (array assignment).
PHP operators 9. Operator priority
PHP operators have priorities. When multiple operators are combined, the one with the highest priority is calculated first. The simple understanding is to multiply and divide first and then add and subtract, so I won’t go into details here.