2007/07
13
function testComparison() {
$this->assertTrue(array() == false); // Pass
$this->assertFalse(array() == 0); //Fail
$this->assertFalse(array() == 1); //Fail
$this->assertTrue(array() == null); //True
}
根据Comparison with Various Types, 在:
bool or null anything Convert to bool, FALSE < TRUE
(bool) null == false, (bool) array() == false;
=> null == array(); false == array();
array anything array is always greater
=> array() > any number;
并不知道php为什么这么设置,明显违反了数学法则嘛。
0 == false;
array() == false;
但
0 == array();
不成立
Last modified on 2007-07-13 00:53










0 Trackbacks