How to differentiate isset and empty
Answers were Sorted based on User's Feedback
Answer / p .g .senthilkumar
isset -> this variable handling functions determine whether
a variable is set . It checks whether a variable is set
even though it is empty.
empty -> as the term itself has already given a sign that
it would related to something that's empty, this variable
handling functions determine whether a variable is empty.
It checks whether a variable has a value whether it's empty
string, zero(0), or not set at all.
Is This Answer Correct ? | 36 Yes | 1 No |
Answer / amit
isset() will ONLY return true when the value of the variable
is not NULL (and thereby the variable is at least defined).
empty() will return true when the value of the variable is
deemed to be an "empty" value, typically this means 0, "0",
NULL, FALSE and empty string, anything else is not empty.
Some examples
FALSE == isset($foo);
TRUE == empty($foo);
$foo = NULL;
FALSE == isset($foo);
TRUE == empty($foo);
$foo = 0;
TRUE == isset($foo);
TRUE == empty($foo);
$foo = 1;
TRUE == isset($foo);
FALSE == empty($foo);
Is This Answer Correct ? | 21 Yes | 2 No |
Answer / rahul shelar
isset is used for checking whether variable is set or not
and empty checks whether it is empty
Is This Answer Correct ? | 19 Yes | 5 No |
Answer / vijay
isset is used to check whether the variable is set or
not ...
where as empty is used to check whether variable contains a
value or not
Is This Answer Correct ? | 12 Yes | 1 No |
Answer / techytech
0, "0",
NULL, FALSE and empty string,
for this value empty() will return TRUE
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / rafique
actually, !isset and empty are one and same thing...
Is This Answer Correct ? | 2 Yes | 31 No |
Php being an open source is there any support available to it?
What is cookie?
List functions available to sort an php array?
What is the default time of cookie in php?
Maine 12th ke bad 2 years ka web designing ka course kiya hai. Php me achcha hu. Ek fresher ko is field me kitna mil sakta hai ?
Write a program to display a table of any given number?
How can we do user authentication without using session/cookies ? For ex:- From page1 accepts user name and password and need to check in all other pages whether the user has logged in or not
Explain what is the difference between session and cookie?
What is a php namespace?
how many type of url?
What is a comment in php?
How can we submit a form without a submit button?