Php Tutorial comparison operator
A comparison operation compares two values to reflect the relationship between two numbers.
Example name result
$ A = $ B is equal to TRUE if $ a is equal to $ B.
$ A ===$ B all equal to TRUE, if $ a is equal to $ B, and their types are the same.
$! = $ B is not equal to TRUE, if $ a is not equal to $ B.
$ A <> $ B is not equal to TRUE, if $ a is not equal to $ B.
$! = $ B is not equal to TRUE. If $ a is not equal to $ B, or they have different types.
$ A <$ B small and TRUE, if $ a is strictly less than $ B.
$ A> $ B is greater than TRUE if $ a is strict with $ B.
$ A <= $ B is less than or equal to TRUE, if $ a is less than or equal to $ B.
$ A >=$ B is greater than or equal to TRUE if $ a is greater than or equal to $ B.
<? Php
$ A = 10;
$ B = 10;
Echo $ a = $ B; // $ a = $ B? 10 = 10 returns 1 True
Echo "<br/> ";
Echo $ a ===$ B; // $ a ===$ B? 10 = 10 returns 1 True
Echo "<br/> ";
$ B = "10 ";
Echo $ a ===$ B; // $ a ===$ B? 10 = "10" return null false to compare two data types, not only the data value but also the data type;
Echo "<br/> ";
$ A = 10;
$ B = 20;
Echo $! = $ B; // $ a is not equal to $ B 10! = 20 returns 1 True
Echo "<br/> ";
Echo $ A <> $ B; // $ a is not equal to $ B 100 <> 20. Return 1 True.
Echo "<br/> ";
Echo $! ==$ B; // $ a is not equal to $ B, or they have different types. 10! = 20 returns 1 True
Echo "<br/> ";
$ C = "10 ";
Echo $! ==$ C; // non-full equality $ a is not equal to $ B, or they have different types. 10! = "10" return null false
Echo "<br/> ";
Echo $ A <$ B; // $ a must be less than $ B 10 <20 returns 1 True
Echo "<br/> ";
Echo $ A> $ B; // $ a must be less than $ B 10> 20. Return null false.
Echo "<br/> ";
Echo $ A <= $ B; // $ a less than or equal to $ B 10 <= 20 returns 1 True
Echo "<br/> ";
Echo $ A >=$ B; // $ a is greater than or equal to $ B 10 >=20 returns null false
Echo "<br/> ";
?>
Comparison of multiple types of operations 1 type of operations 1 type of results
Null or string converts NULL to "" for comparison of numbers or words
Bool or null any other type is converted to bool, FALSE <TRUE
Object built-in classes can define their own comparisons. Different classes cannot be compared. The same classes and arrays are used to compare attributes (in PHP 4). PHP 5 has its own instructions.
String, resource, or number string, resource, or number converts a string and a resource to a number.
Array has a small array of fewer members. If the key in Operation Number 1 does not exist in Operation Number 2, the array cannot be compared; otherwise, the values are compared one by one (see the following example)
Array any other type of array is always larger
Any other object type of the object is always larger.