Actually, each of these will return true with empty(), or when compared to each other with the "==" operator:
$test = array(false, null, 0, '0', '');
foreach($test as $value)
{
if(empty($value))
{
echo "Empty<br />\n";
}
else
{
echo "Full<br />\n";
}
}
Outputs:
Empty
Empty
Empty
Empty
Empty
If you want to verify that something was entered, even if it's a 0, then you need to use the 'identical' or 'not identical' comparison operators ("===" or "!=="):
$test = array(false, null, 0, '0', '');
foreach($test as $value)
{
if(trim($value) === '')
{
echo "Empty<br />\n";
}
else
{
echo "Full<br />\n";
}
}
Outputs:
Empty
Empty
Full
Full
Empty