The isset() function is an inbuilt function in PHP which checks whether a variable is set and is not NULL. This function also checks if a declared variable, array or array key has null value, if it does, isset() returns false, it returns true in all other possible cases.
bool isset( $var, mixed )
Parameters: This function accepts more than one parameters. The first parameter of this function is $var. This parameter is used to store the value of variable.
0 is set with isset function
array is not set.
The empty() function is a language construct to determine whether the given variable is empty or NULL. The !empty() function is the negation or complement of empty() function. The empty() function is considerably equal to !isset() function and !empty() function is equal to isset() function.
0 is considered empty 1 is considered set
Reason to check both function:
The isset() and !empty() functions are similar and both will return the same results. But the only difference is !empty() function will not generate any warning or e-notice when the variable does not exists. It is enough to use either of the function. By incorporating both functions in a program causes time lapse and unnecessary memory usage.
0 is set with isset function 1 is set with !empty function
- Difference between isset() and array_key_exists() Function in PHP
- PHP | isset() Function
- PHP | IntlCalendar isSet() Function
- Node.js | util.types.isSet() Method
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Why does AngularJS include an empty option in select ?
- How to check whether an array is empty using PHP?
- PHP | empty() Function
- Why require_once() function is so bad to use in PHP ?
- How to check an HTML element is empty using jQuery ?
- Program to remove empty array elements in PHP
- Best way to initialize empty array in PHP
- Code valid in both C and C++ but produce different output
- Count numbers upto N which are both perfect square and perfect cube
- How to bind 'touchstart' and 'click' events but not respond to both ?
- Why is === faster than == in PHP ?
- Why PHP script does not create a directory with 777 permissions ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.