所以我有一个多暗阵列。我正在定义一些带有布尔值的数组键:
$geo_entries['hostip']['geoTypes']['country']=true;
$geo_entries['hostip']['geoTypes']['country_short']=true;
$geo_entries['hostip']['geoTypes']['city']=false;
$geo_entries['hostip']['geoTypes']['city_short']=false;
现在我对此进行了print_r()分析,结果如下:
( [country] => 1 [country_short] => 1 [city] => [city_short] => )
如果我错了,现在纠正我,但不是false==0吗?
我尝试快速检查该值(对于布尔值):
if($geo_entries['hostip']['geoTypes']['city']==boolean){
//this returns false...
}
上面的条件返回falsewith ['hostip']['geoTypes']['city']but truewith ['hostip']['geoTypes']['country']。两者之间的唯一区别是city具有 的值false和country具有 的值true。
当我将值定义为0而不是false- 一切正常......
我有一种感觉,我尴尬地错过了一些东西,这导致了这种误解。
有人愿意解释吗?- (为什么false!=0?)