user3081954 user3081954 - 6 months ago 12
PHP Question

What's the difference between 'isset' and '!empty' in php?

I don't understand the difference between 'isset' and '!empty' ..

Because like, if a variable has been set,
isn't it the same as not being empty?

EDIT: I'm fairly new to php, what do you guys mean with the term 'NULL' ?


ISSET checks the variable to see if it has been set. In other words, it checks to see if the variable is any value except NULL or not assigned a value. ISSET returns TRUE if the variable exists and has a value other than NULL. That means variables assigned a "", 0, "0", or FALSE are set, and therefore are TRUE for ISSET.

EMPTY checks to see if a variable is empty. Empty is interpreted as: "" (an empty string), 0 (integer), 0.0 (float)`, "0" (string), NULL, FALSE, array() (an empty array), and "$var;" (a variable declared, but without a value in a class.

For more information, see this article