Possible Duplicate:
Whats the difference between if(!Variable) and if(isset($variable)) ?
In Facebooks php API example they use if($var){ //do something }else{ //do something else}
whick got me thinking about the difference of if($var) and if(isset($var)). The first sure looks neater but can I surely use it?
Using
You’ll test if
$varcontains a value that’s not false — 1 is true, 123 is too, …For more informations about what is considered as true or false, you should take a look at Converting to Boolean.
Using
isset(), you’ll test if a variable has been set — i.e. if any not-null value has been written to it.