我總是包含這兩種情況之一的變量:如何確定false和0之間的差異?
false
- 一些(它也可以
0
)
我在現實中的變量是這樣的:
$index = array_search(1, array_column($var, 'box'));
//=> the output could be something like these: false, 0, 1, 2, ...
現在我想檢測$index
是false
或其他。我怎樣才能實現這樣的條件?
應當注意這些都不不起作用:
if (empty($index)) { }
if (!isset($index)) { }
if (is_null($index)) { }
而且我想這個條件:
if (?) { // $index is false } else { // $index is a number (even 0) }
'$指數== FALSE' – Rizier123
@ Rizier123 EMM的,有趣的,我認爲這將是非常困難。 – stack