1. Arithmetic operators
Common arithmetic operators
Type of operation |
Operator |
Example |
Results |
Take inverse operation |
- |
-$a |
Returns a negative value of $ A |
Addition operation |
+ |
$a + $b |
Returns $ A with $b and |
Subtraction operations |
- |
$a-$b |
Returns the difference between $ A and $b |
Multiplication operations |
* |
$a * $b |
Returns the product of $ A and $b |
Division operation |
/ |
$a/$b |
Returns $ A and $b quotient |
Take the remainder operation |
% |
$a% $b |
Returns the remainder of $ A and $b |
2. Logical operators
logical operators in PHP
Type of operation |
Operator |
Example |
Results |
Logic and |
&& or |
$a && $b or $a and $b |
Returns True when $ A and $b are true, otherwise false |
Logical OR |
|| OR OR |
$a | | $b or $a or $b |
Returns True when $ A or $b is true, otherwise false |
Logical XOR or |
Xor |
$a XOR $b |
When $ A true $b false or $ A fake $b true, returns True, otherwise returns false |
Logical Non- |
! |
! $a |
Returns True when $ A is false, otherwise returns false |
3. Assignment operators
The assignment operator "=" is the most basic operator in PHP, which assigns the value of the expression "=" to the left-hand operand.
In addition, PHP is commonly used to compound assignment operators.
Compound assignment operator
Type of operation |
Operator |
Example |
Results |
Addition Assignment |
+= |
$a + = 5 |
$a plus 5 and assign a value to $ A |
Subtraction Assignment |
-= |
$a-= 5 |
$a minus 5 is assigned a value of $ A |
Multiply Assign Value |
*= |
$a *= 5 |
$a multiplied by 5 for the product assignment to $ A |
Division Assignment |
/= |
$a/= 5 |
The quotient of $a divided by 5 is assigned to $ A |
Assignment of residual value |
%= |
$a%= 5 |
$a is assigned to $ A by dividing the remainder of 5 |
4. Comparison operators
operation type |
operator |
example |
result |
less than |
< |
$a < $b |
returns True if $a value is less than $b value, otherwise false |
greater than |
; |
$a > $b | td> returns True if the value of $a is greater than the value of $b, otherwise false
is less than or equal to |
<= |
$a <= $b |
When the value of $a is less than or equal to Returns True if $b value, otherwise false |
is greater than or equal to |
>= |
$a >= $b |
When the value of $a is greater than or equal to $b, the return is true, otherwise return false |
equal |
= |
$a = = $b |
Returns True if the value of $a equals $b, otherwise returns false |
congruent |
= = = |
$a = = = $b |
returns True if the value of the $a equals the value of the $b, and the $a is equal to the type of the $b, otherwise false |
is not equal |
! = |
$a! = $b or $a <> $b |
returns False if the value of the $a equals the value of $b, otherwise returns true |
not identical |
!== |
$a!== $b |
when $a value equals $b value, and $ A is equal to the type of $b, False is returned, otherwise true |
The above describes the operators in PHP---arithmetic operators, logical operators, assignment operators, comparison operators, including aspects of the content, you want to be interested in PHP tutorial friends helpful.