PHP’s empty and isset function
The best way to check if a variable consists any value or is empty is to use empty function from PHP itself.
$myVar = 0;
if (empty($myVar))
{
echo '$myVar is either 0, empty, or not set at all';
}
Though, while coding in PHP it shouldn’t be confused with isset which checks if a variable is set or not set, whether that variable is empty.
$myVar = 0;
if (isset($myVar))
{
echo '$myVar is set even though it is empty';
}