How to use isset() in PHP -


this question has answer here:

i tried out code:

<?php     if(isset($a) && ($a ==4)) echo "$a ==4"; ?> 

and surprised did not error, because $a not defined. thought 1 needs write

<?php     if(isset($a))         if($a == 4) echo "$a == 4"; ?> 

why first version not throwing error if check isset($a) , ($a ==4) simultaneously? there disadvantage when using short code if(isset($a) && ($a ==4))? not trust it, becomes handy when else branch needed.

php checks if condition left right. isset() returns false doesn't check ($a == 4) aborts if , continues script.

if other way around:

if(($a ==4) && isset($a)) echo "$a ==4"; 

this return undefined notice.


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -