測試
if($res !== false){ echo "未定義通過<br>"; }else{ echo "未定義不通過<br>"; } $res = 0; if($res !== false){ echo "0數字通過<br>"; }else{ echo "0數字不通過<br>"; } $res = "0"; if($res !== false){ echo "0字符串通過<br>"; }else{ echo "0字符串不通過<br>"; } $res = NULL; if($res !== false){ echo "NULL通過<br>"; }else{ echo "NULL不通過<br>"; } $res = ""; if($res !== false){ echo "空字符串通過<br>"; }else{ echo "空字符串不通過<br>"; } $res = array(); if($res !== false){ echo "array()通過<br>"; }else{ echo "array()不通過<br>"; } $res = FALSE; if($res !== false){ echo "FALSE通過<br>"; }else{ echo "FALSE不通過<br>"; } $res = TRUE; if($res !== false){ echo "TRUE通過<br>"; }else{ echo "TRUE不通過<br>"; } $res = 1; if($res !== false){ echo "數字1通過<br>"; }else{ echo "數字1不通過<br>"; }
驗證結果
Notice: Undefined variable: res in D:\xampp\htdocs\test.php on line 6 未定義通過 0數字通過 0字符串通過 NULL通過 空字符串通過 array()通過 FALSE不通過 TRUE通過 數字1通過