'isset()' and '!empty()' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

'isset()' and '!empty()'

What's the difference between 'isset()' and '!empty()' in PHP?

13th Apr 2017, 10:11 PM
HOUCHAT Khaled
HOUCHAT Khaled - avatar
2 Answers
+ 15
ISSET checks the variable to see if it has been set. In other words, it checks to see if the variableis any value except NULL or not assigned a value. ISSET returnsTRUEif 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. - Stackoverflow
13th Apr 2017, 10:20 PM
Agus Mei
Agus Mei - avatar
+ 1
Good
14th Apr 2017, 6:49 AM
HOUCHAT Khaled
HOUCHAT Khaled - avatar