This article introduces the comparison operators in PHP, which has certain reference value. Now I share it with you. Friends in need can refer to it
1. If you compare a number and a string Or comparing strings involving numeric content, the strings will be converted into numerical values and the comparison will be performed according to the numerical values
2,
$a < ;=> $b | Combined comparison operators | When less than, equal to, or greater than than, return a value less than (-1), equal to (0), or greater than 0 (1) respectivelyinteger value. PHP7 starts to provide. |
$a ?? $b ?? $c | NULL merge operator | The first one from left to right exists and An operand that is not NULL . If neither is defined and is not NULL , NULL is returned. Available starting with PHP7. |
switch ("a") { case 0: echo "0";//会运行到这里了因为"a"和数字0比较,字符串被转换成0。如果case “a”放在第一个,那么会运行到case "a"的程序 break; case "a": // never reached because "a" is already matched with 0 echo "a"; break; }
Related recommendations:
PHP uses qqwry.bat to obtain the actual address
The above is the detailed content of php comparison operators. For more information, please follow other related articles on the PHP Chinese website!