How to differentiate isset and empty
Answer Posted / 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 |
Post New Answer View All Answers
Is apache needed for php?
How many types of php frameworks are there?
What is the importance of php?
Tell me can the value of a constant change during the script's execution?
What kind of things have you done on the social side?
What is split function in php?
Does strlen include null?
Explain preg_Match and preg_replace?
What does csrf token mismatch mean?
What are objects in php?
Why php is also called as scripting language?
What is a simple php method to make a cross domain data request?
How is it possible to know the number of rows returned in the result set?
Where to put php files in apache server?
How values in arrays are indexed?