I want to validate a field which is required. I am using following condition to check whether the field is not empty:
isset($value) && !empty($value)
But if I write 0 in the fields, it will still say the field is required. The empty() function considers 0 as an empty value as told in PHP manual but what else should I do? I have tried writing many conditions but they didn't work as expected.
I saw user contributions and found:
empty($var) && !is_bool($var)
I tried adding it to my condition like this but didn't work:
isset($value) && !empty($value) && is_bool($value)
$valuewhen youvar_dumpit?