对于这个数组($options)
:
Array (
[0] => 0
[1] => 1
[2] => 2
)
PHP 返回 TRUE:
$this->assertTrue( in_array('Bug', $options ) ); // TRUE
$this->assertTrue( in_array('Feature', $options ) ); // TRUE
$this->assertTrue( in_array('Task', $options ) ); // TRUE
$this->assertTrue( in_array('RockAndRoll', $options ) ); // TRUE
Why?
这是因为0 == "string" is true http://php.net/manual/types.comparisons.php, and 0
是数组的一个元素。
设置参数$strict
in in_array
为真:
$this->assertTrue( in_array('Bug', $options, true) );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)