The output of the code below is "fail" but if we pass 1 to $b as $b=1 then it will give the output as "pass". Can anybody tell me why this if condition holds true only for 0?
<?php
$a="abcd";
$b=0;
if($a == $b)
{
echo "fail";
}
else
{
echo "pass";
}
?>
That is because of PHP type juggling with == operator. The full table is given here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With