isset() and empty() are often confused as inverses of each other, but that is NOT the case!
isset()
empty()
The following values are considered "empty" but also "set and not NULL":
empty(0); //returns TRUE empty(''); //returns TRUE empty(FALSE); //returns TRUE isset(0); //returns TRUE isset(''); //returns TRUE isset(FALSE); //returns TRUE
But here is the difference between isset() and empty():
empty(NULL); //returns TRUE empty("foo"); //returns FALSE empty(5); //returns FALSE isset(NULL); //returns FALSE isset("foo"); //returns TRUE isset(5); //returns TRUE
NULL is both "empty" and "not set."
A string of non-zero length and a non-zero number are both "not empty" and again "set and not NULL."
Hopefully that's clear now! Any questions?
Good article. Just found another over at Tutorial Arena that takes a more in depth look at the difference between the two: <a href="http://www.tutorialarena.com/blog/php-isset-vs-empty.php">PHP isset vs empty</a>
Hope these 2 articles help someone.