Is there a difference between isset
and !empty
. If I do this double boolean check, is it correct this way or redundant? and is there a shorter way
empty()
function:Returns FALSE
if var
has a non-empty and non-zero value.
That’s a good thing to know. In other words, everything from NULL
, to 0
to “” will return TRUE
when using the empty()
function.
isset()
function returns:Returns TRUE
if var
exists; FALSE
otherwise.
In other words, only variables that don’t exist (or, variables with strictly NULL
values) will return FALSE
on the isset()
function. All variables that have any type of value, whether it is 0
, a blank text string, etc. will return TRUE
.