Stupid question, I know, but if I don’t know whether a variable $var is set or not, should I use
isset($var) && !empty($var)
to check if it has any value in it, or is
!empty($var) enough? Would there be a problem if $var is null in the second case?
issetandemptyare both language constructs. Andempty()internally does anissetcheck first, then negates that, or alternatively also checks for values that equateFALSEin boolean context.So yes,
!empty()is sufficient.