Diff between isset () and empty () in php


This question already has an answer here:

  • What's the difference between 'isset()' and '!empty()' in PHP? 6 answers

I want to check whether monday is a holiday,if yes assign the value to $ts else go to tuesday.

  if (isset($list->hours_from_MON)) {
            $ts = $list->hours_from_MON;

        } else  (isset($list->hours_from_TUE)) {
            $ts = $list->hours_from_TUE;

The data in database is like {"hours_from_Mon":"","hours_from_Tue":"2am to 5pm"}

Here in the above case it should take ts as 2am to 5pm,but it is accepting "",i think i should use  

    if (!empty($list->hours_from_MON)) {
            $ts = $list->hours_from_MON;          

        } else  (!empty($list->hours_from_TUE)) {
            $ts = $list->hours_from_TUE;

   So that it will go to tue if,mon has no value.Am i right?Can some one help me.

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.

EMPTY checks to see if a variable is empty. Empty is interpreted as: " " (an empty string), 0 (0 as an integer), 0.0 (0 as a float), "0" (0 as a string), NULL, FALSE, array() (an empty array), and "$var;" (a variable declared, but without a value in a class.

source from click here