I need to check if an age is empty so I do:
empty($age);
But when the age is 0, it still thinks it is empty.
How can I check if the age is empty but allow a 0 to validate as not empty?
I need to check if an age is empty so I do:
empty($age);
But when the age is 0, it still thinks it is empty.
How can I check if the age is empty but allow a 0 to validate as not empty?
You have to make a hack, for example:
if($age != "" && $age == false){
// Age = 0
}
You can use is_null() too.
Why do not you define it all your own
function myempty($x)
{
if(empty($x) || $x=0)
retutn true;
else
return false;
}