本文參考 http://php.net/manual/en/types.comparisons.php。php
1. isset數組
bool isset ( mixed $var [, mixed $... ] )ide
Determine if a variable is set and is not NULL.
變量值被設置,並且其值不爲 NULL,那麼就會返回 true。函數
另外這個函數能夠被用來檢查數組中的元素是否存在且值不爲 NULL。測試
2. emptyspa
bool empty ( mixed $var ).net
A variable is considered empty if it does not exist or if its value equals FALSE. empty() does not generate a warning if the variable does not exist.
變量不存在或者其值爲 FALSE,empty 函數都返回真。另外 empty 只能處理變量,沒法處理表達式的結果。code
3. PHP 中一些奇怪的值【背下來】blog
1 $x = ''; // 爲 false 2 $x = null; // 沒有值,沒有類型,爲 false 3 var $x; // 沒有值,沒有類型,爲 false 4 $x is undefined; // 沒有值,沒有類型,爲 false 5 $x = array(); // 爲 false 6 $x = false; // 爲 false 7 $x = 0; // 爲 false 8 $x = '0'; // 爲 false 9 $x = 'false' // 爲 true
上面這些值得真值測試都是 loose comparison。get