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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -