if ($opts['width'] == 'fs' || $opts['height'] == 'fs' || $opts['ratio'] == 'fs') {
var_dump($opts); // result of this see bellow
}
var_dump($opts)
内的结果(!)if-statement:
array(3) {
'width' => int(200)
'height' => int(0)
'ratio' => int(0)
}
这怎么可能?数组的值都不是(stirng)fs?
答案 0 :(得分:3)
因为0 == 'fs'
。请参阅 conversion table 。
PHP有===
运算符来比较值和类型。
更广泛的表:Type-juggling and (strict) greater/lesser-than comparisons in PHP