Conclusion: empty($v_msg) is only function that treats NULL, '', never set, and unset() variables the same way.
Therefore variables can be "emptied" using any of these methods:
- $v_msg = '';
- $v_msg = NULL;
- unset($v_msg);

Positive Tests

1) Test of Variables Set to NULL - i.e. $v_msg = NULL


The NULL var is NOT set - i.e. isset($v_msg) == FALSE
The NULL var is empty - i.e. empty($v_msg) == TRUE
The NULL var is null - i.e. is_null($v_msg) == TRUE

2) Test of Variables Set to '' - i.e. $v_msg = ''


The empty var is set - i.e. isset($v_msg) == TRUE
The empty var is empty - i.e. empty($v_msg) == TRUE
The empty var is NOT null - i.e. is_null($v_msg) == FALSE

3) Test of Variables that has Never Been Set


The no var is NOT set - i.e. isset($v_msg) == FALSE
The no var is empty - i.e. empty($v_msg) == TRUE
The no var is null - i.e. is_null($v_msg) == TRUE

4) Test of Variables that have been Set, but then are unset - i.e. unset($v_msg)


The unset variable is NOT set - i.e. isset($v_msg) == FALSE
The unset variable is empty - i.e. empty($v_msg) == TRUE
The unset variable is null - i.e. is_null($v_msg) == TRUE

Negative Tests

5) Test of Variables Set to NULL - i.e. $v_msg = NULL


The NULL var is NOT set - i.e. !isset($v_msg) == TRUE
The NULL var is NOT, NOT empty - i.e. !empty($v_msg) == FALSE
The NULL var is NOT, NOT null - i.e. !is_null($v_msg) == FALSE

6) Test of Variables Set to '' - i.e. $v_msg = ''


The empty var is NOT, NOT set - i.e. !isset($v_msg) == FALSE
The empty var is NOT, NOT empty - i.e. !empty($v_msg) == FALSE
The empty var is NOT null - i.e. !is_null($v_msg) == TRUE

7) Test of Variables that has Never Been Set


The no var is NOT set - i.e. !isset($v_msg) == TRUE
The no var is NOT, NOT empty - i.e. !empty($v_msg) == FALSE
The no var is NOT, NOT null - i.e. !is_null($v_msg) == FALSE

8) Test of Variables that have been set, but then are unset - i.e. unset($v_msg)


The unset variable NOT is set - i.e. !isset($v_msg) == TRUE
The unset variable NOT, NOT is empty - i.e. !empty($v_msg) == FALSE
The unset variable NOT, NOT is null - i.e. !is_null($v_msg) == FALSE

Return to Test Directory Home Page