Why check both isset() and !empty()

php

Solution

This is completely redundant. `empty` is more or less shorthand for `!isset($foo) || !$foo`, and `!empty` is analogous to `isset($foo) && $foo`. I.e. `empty` does the reverse thing of `isset` plus an additional check for the truthiness of a value.

Or in other words, `empty` is the same as `!$foo`, but doesn't throw warnings if the variable doesn't exist. That's the main point of this function: do a boolean comparison without worrying about the variable being set.

The manual puts it like this:

`empty()` is the opposite of `(boolean) var`, except that no warning is generated when the variable is not set.

You can simply use `!empty($vars[1])` here.

Problem

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 to do the same thing? ``` isset($vars[1]) AND !empty($vars[1]) ```

Original source