You cannot use empty(or isset) if you expect to exist $foo. This means that if, in accordance with your logic, the program $fooshould exist at the moment:
if ($foo === '')
Then do not follow these steps:
if (isset($foo))
if (empty($foo))
undefined. . , isset empty , PHP . :
$foo = $bar;
if (empty($føø)) ...
, true, $bar ? , undefined. , PHP :
if (!$føø) ...
: undefined føø on line...
, == false (!) empty .
, , . , $foo === '' strlen($foo) == 0 - , , , - .