From: http://php.chinaunix.net/manual/zh/language.operators.comparison.php
| Example |
Name |
Result |
| $ A = $ B |
Equal |
TrueIf $ A is equal to $ B. |
| $ A ===$ B |
Full |
TrueIf $ A is equal to $ B, and their types are the same. (Introduced in PHP 4) |
| $! = $ B |
Not Supported |
TrueIf $ A is not equal to $ B. |
| $ A <> $ B |
Not Supported |
TrueIf $ A is not equal to $ B. |
| $! ==$ B |
Incomplete |
TrueIf $ A is not equal to $ B, or they are of different types. (Introduced in PHP 4) |
| $ A <$ B |
Xiaohe |
TrueIf $ A is strictly less than $ B. |
| $ A> $ B |
Greater |
TrueIf $ A is strict with $ B. |
| $ A <= $ B |
Less than or equal |
TrueIf $ A is less than or equal to $ B. |
| $ A> = $ B |
Greater than or equal |
TrueIf $ A is greater than or equal to $ B. |
If you compare an integer with a string, the string is converted to an integer. Compare two numeric strings as integers. This rule also applies to switch statements.
For multiple types, comparison operators are compared according to the following table (in order ).
Compare multiple types
| Operation Number 1 Type |
Operation Number 1 Type |
Result |
| Null or string |
String |
SetNullConvert to "" For comparison of numbers or words |
| Bool or null |
Any other type |
Convert to bool,False<True |
| Object |
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 and compares it by common mathematics. |
| Array |
Array |
The array with fewer members is small. If the key in Operation Number 1 does not exist in Operation Number 2, the array cannot be compared. Otherwise, compare the values one by one (see the following example) |
| Array |
Any other type |
Array is always larger |
| Object |
Any other type |
The object is always larger. |