I tried out this code:
<?php
if(isset($a) && ($a ==4)) echo "$a ==4";
?>
and I was surprised that I did not get an error, because $a is not defined. I thought one needs to write
<?php
if(isset($a))
if($a == 4) echo "$a == 4";
?>
Why is the first version not throwing an error if I check isset($a)
and ($a ==4)
simultaneously? Is there any disadvantage when using the short code if(isset($a) && ($a ==4))
? I do not trust it, but it becomes really handy when an else branch is needed.