1
qiayue 2013-06-11 22:35:53 +08:00
第一句你用三个等号试一试?
|
2
kennedy32 OP |
5
Sunyanzi 2013-06-12 17:05:15 +08:00
RTFM ...
-------------------- If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement. The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value. <?php var_dump(0 == "a"); // 0 == 0 -> true var_dump("1" == "01"); // 1 == 1 -> true var_dump("10" == "1e1"); // 10 == 10 -> true var_dump(100 == "1e2"); // 100 == 100 -> true switch ("a") { case 0: echo "0"; break; case "a": // never reached because "a" is already matched with 0 echo "a"; break; } |
6
msg7086 2013-06-12 17:30:17 +08:00
var_dump("1" == "01"); // 1 == 1 -> true
var_dump("10" == "1e1"); // 10 == 10 -> true 对这两句话感到绝望了…… |
8
F0ur 2013-06-18 01:21:46 +08:00
==是等于 !=是不等于
===是类型和数值都相等,曰恒等 !==是类型或数值不相等 |
9
jevonszmx 2013-07-02 21:55:48 +08:00
1、==或者!=,手册:如果比较一个整数和字符串,则字符串会被转换为整数。
2、!==是===的相反,会同时比较值和类型的。 |