This is mainly related to php non-type languages, such as NULL, FALSE, array (), "", 0, "0 & Prime; if they are equal, but if you determine the true return value of a value, you can use =
$ A = 0;
$ B = FALSE;
$ A = FALSE is not true, but $ B = FALSE is true. If yes, $ a = FALSE and $ B = FALSE are both true.
The ===operator is still very useful. Some built-in functions in php return a value if they succeed, and false if they fail, if it succeeds but the return value is a null value such as "" or 0, how do you determine the success or failure? You can use = to distinguish variable types.
Refer:
Comparison Operators
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.
The code is as follows: |
Copy code |
<? Php Var_dump (0 = "a"); // 0 = 0-> true Var_dump ("1" = "01"); // 1 = 1-> true Var_dump ("1" = "1e0"); // 1 = 1-> true Switch (""){ Case 0: Echo "0 "; Break; Case "a": // never reached because "a" is already matched with 0 Echo ""; Break; } ?> |