Operators in PHP---arithmetic operators, logical operators, assignment operators, comparison operators

WBOY
Release: 2016-07-28 08:25:27
Original
1249 people have browsed it

1. Arithmetic operators

                                                  

Operation typeInversion operationAddition operationSubtraction operation Multiplication operation Return $ The quotient of a and $b$a % $breturns the remainder of $a and $b                                                                                                                                       out out out out Operation typeLogical AND
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
+ remainder operation %
2. logic Operators
Operator Example Result

&& or and

$a && $b or $a and $b

When both $a and $b are true, return true, otherwise return falseWhen $a or $b is true, return true, otherwise return falseWhen $a is true $b is false or $a is false $b is true, return true, otherwise return false 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. Curber +=
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 In addition, the compound assignment operator is also commonly used in PHP.值 赋 Composite assignment operator Computing type
Example Results Add method

$a += 5

$a plus 5 and assign to $a 5 The difference is assigned to $a. The product of $a multiplied by 5 is assigned to $a.

Division assignment

/=%=

4. Comparison operator

$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
When the value of $a is greater than the value of $b, then return true, otherwise return falseWhen the value of $a is less than or equal to the value of $b, it returns true, otherwise it returns false When the value of $a is greater than or equal to the value of $b, it returns true, otherwise it returns false When$ If the value of a is equal to the value of $b, return true, otherwise return false When the value of $a is equal to the value of $b, and The types of $a and $b are also equal, then return true, otherwise return false when $a If the value is equal to the value of $b, return false, otherwise return true When the value of $a is equal to the value of $b, and $a The type of $b is also equal, then false is returned, otherwise true is returned 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.
Operation type operator Example The result
is less than <$a < $bWhen 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
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template