# What is the difference between 'isset()' and '!empty()' in PHP?

PHPServer Side ProgrammingProgramming

## Isset function

ISSET checks the variable to see if it has been set. In other words, it checks to see if the variable is any value except NULL or not assigned a value. ISSET returns TRUE if the variable exists and has a value other than NULL. That means variables assigned a "", 0, "0", or FALSE are set, and therefore are TRUE for ISSET.

## Example

Live Demo

<?php
$val = '0'; if( isset($val)) {
print_r(" $val is set with isset function <br>"); }$my_array = array();

## Example

Live Demo

<?php
$temp_val = 0; if (empty($temp_val)) {
echo $temp_val . ' is considered empty'; } echo "nn";$new_val = 1;
if (!empty($new_val)) { echo$new_val . ' is considered set';
}
?>

## Output

This will produce the following output −

0 is considered empty 1 is considered set`
Published on 07-Apr-2020 11:54:20