Do you know the difference between three equal signs (===) and two equal signs (==) in PHP? This article introduces it in detail for everyone. Friends in need can take a look.
To talk about the difference between three equal signs (===) and two equal signs (==) in PHP, let’s first look at an example: For example, a function will return the following situations: 1. Numbers greater than 0 2. Numbers less than 0 3. A number equal to 0 (that is, 0) 4. False (on failure) When quoting, to capture the failure situation, you must use ===, not == Because == will not only match the 4th case, but also the 3rd case, because 0 is also false! Three equal signs mean that the types of comparison objects must also be consistent. Two equal signs indicate that the condition is satisfied as long as the values are equal. Added: $a='2';//Character type 2 $b=2;//numeric type 2 $a==$b, is correct, both are 2 $a===$b is incorrect because $a is character type and $b is numeric type. Although the value is the same, the type is different. There is also the "0" mentioned in "linvo1986 - Level 6". |