Value of variable ($var) | if($var) | isset | empty | is_null |
---|---|---|---|---|
$var=1; | true | true | false | false |
$var="php"; | true | true | false | false |
$var=" "; (space) | true | true | false | false |
$var=TRUE; | true | true | false | false |
$var=0; | false | true | true | false |
$var=0.0; | false | true | true | false |
$var="0"; | false | true | true | false |
$var=""; (an empty string) | false | true | true | false |
$var=FALSE; | false | true | true | false |
$var=NULL; | false | false | true | true |
$var (a variable declared, but without a value) | *false* | false | true | *true* |
undefined | *false* | false | true | *true* |
$var=array(1); | true | true | false | false |
$var=array(); (an empty array) | false | true | true | false |
* "Notice: Undefined variable: ..." also occurs.