1. Arithmetic operators
Operator | Example | Result | |
- | -$a | Returns the negative value of $a | |
+ | $a + $b | Return $a with The sum of $b | |
- | $a - $b | Returns the difference between $a and $b | |
+ | Return $ The quotient of a and $bremainder operation | % | |
returns the remainder of $a and $b | 2. logic Operators | out out out outOperation type | |
Operator | Example | Result | Logical AND |
&& or and
$a && $b or $a and $b
logical or | | | or or | $a || $b or $a or $b | |
logical exclusive OR | xor | $a xor $b | |
logical not ! | !$a | When $a is false, return true, otherwise return false | |
3. Assignment operator | The assignment operator "=" is the most basic in PHP Operator, that is, assign the value of the expression on the right side of "=" to the operand on the left.In addition, the compound assignment operator is also commonly used in PHP.值 赋 Composite assignment operator | Computing type | |
Example | Results | Add method |
Division assignment
$a /= 5 | $a divided by 5 is assigned the quotient of $a | Take the remainder and assign | ||||||||||||||||||||||||||||||||||||
$a %= 5 | $a divided by 5, the remainder is assigned to $a |
Operation type | operator | Example | The result |
is less than | < | $a < $b | When the value of $a is less than $b $b |
less than or equal to | <= | $a <= $b | |
greater than or equal to | >= | $a >= $b | |
Equal | == | $a == $b | |
Congruent | === | $a === $b | |
not equal | != | $a != $b or $a <> $b | |
not equal | !== | $a !== $b | |
The above has introduced the operators in PHP---arithmetic operators, logical operators, assignment operators, comparison operators, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials. |