php中值的真真假假

你是否还模糊???

 null, "b" => "","c" => 0];
echo "array_key_exists,值为 null 为:";
var_export(array_key_exists("a", $arr));
echo "\nisset 值为 null 时,判断为:";
var_export(isset($arr["a"]));
echo "\nisset 空字符串时返回:";
var_export(isset($arr["b"]));
echo "\n isset 0 时返回:";
var_export(isset($arr["c"]));
echo "\nempty null 返回:";
var_export(empty($arr["a"]));
echo "\nempty 空字符串 返回:";
var_export(empty($arr["b"]));
echo "\nempty 0 返回:";
var_export(empty($arr["c"]));
echo "\n";
echo $arr["a"] ? "null value is true":"null value is false";
echo "\n";
echo $arr["b"] ? "空字符串 is true":"空字符串 is false";
echo "\n";
echo $arr["c"] ? "0 is true":"0 is false";
?>

你可能感兴趣的:(php)