php : How to check a field have blank/empty/NULL value?
php, validation
Solution
doing strtotime will return false if it cannot convert to a time stamp.
$mo = strtotime($_POST['MondayOpen']);
if ($mo !== false)
{
//valid date was passed in and $mo is type int
}
else
{
//invalid date let the user know
}
Problem
I want to display an error when a variable have a BLANK value or EMPTY or NULL value. for example variable is shown below: ``` $mo = strtotime($_POST['MondayOpen']); ``` and `var_dump($_POST['MondayOpen'])` returns `string(0) "".` Now I go with below approach First want to find which type of variable `$mo` is ?(string or integer or other) Which function is better to find that `$mo` having no value. I conduct a test with `$mo` and got these results ``` is_int($mo);//--Return nothing is_string($mo); //--Return bool(false) var_dump($mo); //--Return bool(true) var_dump(empty($mo));//--Return bool(true) var_dump($mo==NULL);//--Return bool(true) var_dump($mo=='');//--Return nothing ``` Please suggest an optimum and right approach to check the variable integrity