could anyone explain why float 0 is empty? The code below will show “weird”
$empty = (float)"0";
if($empty == "")
echo "weird";
On the other hand if i were to the code below, it will never show “weird”.
$empty = (float)"0.01";
if($empty == "")
echo "weird";
This is because in PHP the following expressions are true:
not because
$emptyhere is the empty string"".You can perform a typed equality check using
===, and these expressions will appear false, as expected: