When two variables are compared, the & quot; and & quot; or & quot; operations have two types of operators, that is, they have different priorities (see below) comparison Operators, just like the names, allow you to compare two values.
Operator
Arithmetic operators
Do you still remember the basic mathematics in the school? This is like that.
Example operator result
$ A + $ B plus $ a plus $ B
$ A-$ B minus $ a minus $ B
$ A * $ B multiply by $ a by $ B
$ A/$ B except $ a divided by $ B
$ A % $ B modulo $ a divided by the remainder of $ B
If both operands are integer values (the string is converted to an integer value), the division sign ("/") returns an integer value (the value of the entire division ). If any of the operands is a floating point value, the floating point division is performed. The string operator only has the -- string connector (".").
$ A = "Hello ";
$ B = $ a. "World! "; // Now $ B =" Hello World! "
The basic value assignment operator is "= ". First, you think this is an equal sign, wrong. It actually means that the operand on the left gets the value of the right expression (that is, "value assignment "). The value of a value assignment expression is the assigned value. For example, the value of expression $ a = 3 is 3. This allows you to do complex things like this:
$ A = ($ B = 4) + 5; // Now $ a equals 9, and $ B is 4.
In addition to the basic value assignment, there are also "composite operators ". You can perform variable self-composite operations on all binary numbers and strings. For example: $ a = 3; $ a + = 5; // Set $ a to 8, that is, $ a = $ a + 5; $ B = "Hello "; $ B. = "There! "; // Set $ B to" Hello There! ", Just like $ B = $ B." There! "; Bitwise operators allow you to set or reset the specified data.
Example operator result
If $ a & $ B and $ a and $ B are both set, the result is set.
$ A | $ B, $ a, or $ B if one of them is set, the result is set to a bit.
~ $ A if not $ a is not set, the result is set.
Logical operators
Example operator result
$ A and $ B and $ a and $ B are both true, and the result is true.
$ A or $ B or $ a or $ B if one of them is true, the result is true.
$ A xor $ B is different or $ a and $ B are not both true, the result is true.
! $ A. if not $ a is false, the result is true.
$ A & $ B if both $ a and $ B are true, the result is true.
$ A | $ B, $ a, or $ B. If one of them is true, the result is true.
When two variables are compared, there are two operators for "and" and "or" operations, that is, the two operators have different priorities (see below) comparison operators, just like names, you can compare two values.
Example operator result
$ A ==$ B equals $ a equals $ B and the result is true.
$! = $ B not equal to $ a not equal to $ B the result is true
$ A <$ B less than $ a less than $ the result is true.
$ A> $ B greater than $ a greater than $ B, the result is true.
$ A <= $ B less than or equal to $ a less than or equal to $ B results in true
$ A >=$ B greater than or equal to $ a greater than or equal to $ B, the result is true.