84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
var_dump( (pack("C" , 1)<<1) ==pack("C" , 1) );为什么是true呢
认证高级PHP讲师
When it comes to PHP comparison, type conversion1, pack("C", 1)<<1, the result is int(0)2, pack("C", 1), the result is string(" ")
In fact, it is simplified to the comparison of 0 == ""
PHP 在比较的时候,如果类型不相等,会进行类型转换 Here string("") will be converted to int type, that is, it will become int(0), so it returns true
PHP 在比较的时候,如果类型不相等,会进行类型转换
You have to judge strictly, you can use ===
===
var_dump( (pack("C" , 1)<<1) ===pack("C" , 1) ); The result is false
When it comes to PHP comparison, type conversion
1, pack("C", 1)<<1, the result is int(0)
2, pack("C", 1), the result is string(" ")
In fact, it is simplified to the comparison of 0 == ""
PHP 在比较的时候,如果类型不相等,会进行类型转换
Here string("") will be converted to int type, that is, it will become int(0), so it returns true
You have to judge strictly, you can use
===
var_dump( (pack("C" , 1)<<1) ===pack("C" , 1) ); The result is false