将布尔值转换为整数时,true 将转换为 1,false 将转换为 0
来自 PHP 手册: http: //php.net/manual/en/language.types.integer.php
从布尔值
FALSE 将产生 0(零),TRUE 将产生 1(一)。
还:
-1 被认为是 TRUE,就像任何其他非零(无论是负数还是正数)数字一样!
true < 0 => false => true < (bool)(0) => true < false => 1 < 0 = false
0 < true => true => (bool)(0) < true => false < true => 0 < 1 = true
true < 1 => false => true < (bool)(1) => true < true => 1 < 1 = false
1 < true => false => (bool)(1) < true => => true < true => 1 < 1 = false
true < -1 => false => true < (bool)(-1) => true < true => 1 < 1 = false
-1 < true => false => (bool)(-1) < true => true < true = > 1 < 1 = false
false < 0 => false => false < (bool)(0) => false < false => 0 < 0 = false
0 < false => false => (bool)(0) < false => false < false => 0 < 0 = false
false < 1 => true => false < (bool)(1) => false < true => 0 < 1 = true
1 < false => false => (bool)(1) < false => true < false => 1 < 0 = false
false < -1 => true => false < (bool)(-1) => false < true => 0 < 1 = true
-1 < false => false => (bool)(-1) < false => true < false => 1 < 0 = false