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 is php oop?
Tell me can you extend a final defined class?
Is learning php easy?
Why use php artisan serve?
Are react hooks stable?
What is the use of trim in php?
What is the function in PHP do not return a timestamp?
Explain the difference between session and cookies in php?
What is design pattern? Explain all including singleton pattern?
What is needed to be able to use image function?
Explain setcookie() function in php?
Write a hello world program using variable?
Where are the persistent cookies stored on your computer?
What is the difference between Split and Explode in PHP?
How to create reusable code in php?