Array operator (+), string operator (.), logical operators (amp; AND | ORXOR) have a need for friends can refer to the reference. php array operator $ a + $ B Union $ a and $ B Union. nbs... array operator (+), string operator (.) AND logical operators (& AND | or xor). For more information, see.
Php array operators
$ A + $ B join $ a and $ B.
$ A = $ B is equal. if $ a and $ B have the same key/value pair, the value is TRUE.
$ A ===$ B. TRUE if $ a and $ B have the same key/value pairs and the order and type are the same.
$! = $ B. If $ a is not equal to $ B, it is TRUE.
$ A <> $ B: TRUE if $ a is not equal to $ B.
$! = $ B incomplete. if $ a is not all equal to $ B, TRUE is returned.
The only array operator in PHP is the + operator. it attaches the array on the right to the array on the left, but duplicate key values are not overwritten.
The instance code is as follows:
$a = array("a" => "apple", "b" => "banana"); $b = array("a" =>"pear", "b" => "strawberry", "c" => "cherry"); $c = $a + $b; var_dump($c);
After the script is executed, the script displays:
The instance code is as follows:
array(3) { ["a"]=> string(5) "apple" ["b"]=> string(6) "banana" ["c"]=> string(6) "cherry" }
If the elements in the array have the same key name and value, the comparison is equal.
Example #1 compare arrays
The instance code is as follows:
"banana", "0" => "apple"); var_dump($a == $b); // bool(true) var_dump($a === $b); // bool(false) ?>
String operators
There are two string operators. the first is the concatenation operator (". ), it returns the string after the left and right parameters are connected. the second is the join value assignment operator (". = "), it attaches the parameter on the right to the parameter on the left
The instance code is as follows:
The instance code is as follows:
Logical operators
Example of logical operators in the following table
$ A and $ B And (logical and) TRUE, if both $ a And $ B are TRUE.
$ A or $ B Or (logical or) TRUE, if $ a Or $ B is TRUE.
$ A xor $ B Xor (logical exclusive or) TRUE. if either $ a or $ B is TRUE, but not both.
! $ A Not (logical Not) TRUE, if $ a is Not TRUE.
$ A & $ B And (logical And) TRUE, if both $ a And $ B are TRUE.
$ A | $ B Or (logical Or) TRUE, if $ a Or $ B is TRUE.
"And" and "or" have two different operators because they have different operation priorities.
The instance code is as follows:
The instance code is as follows:
The output of the preceding routine is similar:
bool(true)bool(false)bool(false)bool(true)