php判斷 !==false


測試

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通過

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM