1, bitwise operators
The bitwise operator is used to set the specified bit of an integer number, and if the operand is a string, the ASCII value of the string is manipulated.
Type of operation |
Operator |
Example |
Results |
Bitwise-AND |
& |
$a & $b |
Place $ A and 1 in the $b at 1 and the rest to 0 |
Bitwise OR |
| |
$a | $b |
Place $ A in 1 or $b to 1 in 1 and 0 for the rest |
Bitwise XOR OR |
^ |
$a ^ $b |
Add $ A to the $b with a different position of 1 and the rest to 0 |
Bitwise non- |
~ |
~ $a |
The position of 1 in the $a is 0, and the position of 0 is 1 |
Move left |
<< |
$a << $b |
When a bit in $ A moves to the left $b times, each move is equal to multiplying by 2 |
Move right |
>> |
$a >> $b |
When a bit in $ A moves to the right $b times, each move is equivalent to dividing by 2 |
2. Increment decrement operator
Type of operation |
Operator |
Example |
Results |
Pre-increment |
++ |
+ + $a |
$a increment by 1 and return $ A |
Post-increment |
++ |
$a + + |
Return $ A first, then $ A from 1 |
Before descending |
-- |
--$a |
$a subtract 1, and then return $ A |
After descending |
-- |
$a-- |
Return $ A first, then $ A minus 1 |
3, ternary operator
The ternary operator (?:), also called the trinocular operator, acts like a SELECT statement that selects one of the two other expressions based on the true or false of an expression. Use the following:
Logical expression? Expression 1: Expression 2
Returns expression 1 if the logical expression is true, otherwise returns the expression 2
4. String operators
In PHP, you often see two strings through a small dot "." Connected, the dot is the string operator. With the string operator, you can concatenate any number of strings into a single string.
If there are numeric variables in the operand of the string connector, the PHP engine will convert the its first to a string and then concatenate the strings.
5. Array operators
Type of operation |
Operator |
Example |
Results |
Union operations |
+ |
$a + $b |
Appends a $ A element to the back of the $b, and the duplicate key value is not overwritten |
Equality comparison |
== |
$a = = $b |
Returns True when $ A and $b have the same key value pair, otherwise returns false |
Comparison of congruent |
=== |
$a = = = $b |
When $ A has the same key-value pair as the $b, and the order and type of the elements are the same, returns true, otherwise false |
Unequal comparison |
! = or <> |
$a! = $b |
When $ A and $b have the same key value pair, return false, otherwise return true |
Non-congruent comparison |
!== |
$a!== $b |
When $ A has the same key-value pair as the $b, and the order and type of the elements are the same, returns FALSE, otherwise returns true |
6. Type operator
In PHP, the type operator instanceof commonly used to determine whether a variable belongs to an instance of a class.
Operators in PHP----bit operators, increment-decrement operators, ternary operators, string operators, array operators, type operators, error control operators