天天看點

php變量布爾值驗證

使用 PHP 函數對變量 $x 進行比較

表達式 gettype() empty() is_null() isset() boolean : if($x)
$x = ""; string TRUE FALSE
$x = null; NULL
var $x;
$x is undefined
$x = array(); array
$x = false; boolean
$x = true;
$x = 1; integer
$x = 42;
$x = 0;
$x = -1;
$x = "1";
$x = "0";
$x = "-1";
$x = "php";
$x = "true";
$x = "false";

繼續閱讀