It depends what you are looking for, if you are just looking to see if it is empty just use
empty
as it checks whether it is set as well, if you want to know whether something is set or not use isset
.Empty
checks if the variable is set and if it is it checks it for null, "", 0, etcIsset
just checks if is it set, it could be anything not null
With
empty
, the following things are considered empty:- "" (an empty string)
- 0 (0 as an integer)
- 0.0 (0 as a float)
- "0" (0 as a string)
- NULL
- FALSE
- array() (an empty array)
- var $var; (a variable declared, but without a value in a class)
http://stackoverflow.com/questions/7191626/isset-and-empty-what-to-use?lq=1
ReplyDelete