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
What the use of var_dump()?
What are psrs? Choose 1 and briefly describe it?
What does the expression exception::__tostring means?
What does $this do in php?
Which software is used to run php programs?
Which is the best web server?
What is difference between ksort() and usort() functions.
Is php a programming language?
What changes I have to do in php.ini file for file uploading?
Explain different sorting function in php?
What is the use of inner join in mysql?
What is the difference between core php and php?
What is a PHP accelerator?
How we get browser details of clients machine?
How can we increase execution time of a php script?