Home >Backend Development >PHP Tutorial >Analysis of the difference between three equal signs '===' and two equal signs '==' in PHP
Let’s analyze the difference between three equal signs === and two equal signs == in PHP. Friends in need can refer to it.
Recently, I want to study the specific difference between "===" and "==" in PHP. In fact, "===" is also used for comparison, but the comparison requirements are more stringent. It will require that the types on both sides are the same; For example: When $a=8; if($a==8.0) or if($a==8) both return TRUE; But if($a===8.0) returns false, because the two types are different, only if($a===8) returns true;Suppose, 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) At this time, if you need to capture the failure situation, you must use === instead of ==. why? Because == will not only match the 4th situation, but also the 3rd situation, because 0 is also false. |