This is driving me crazy! I have a form and am supposed to do some validation on a text input called “range”.
function splitRange($range){
if($range == ''){
$returnedValue = '';
return $returnedValue;
}
// some other code here
return false;
}
// ----------------
$myRange = splitRange($_POST['range']);
if($myRange == false){
echo 'error';
}
This keeps returning false and echoing ‘error’ when “range” is left blank!
Your final comparison at the end states
Which means “if
$myRangeis false-y, echo ‘error'”In other words,
and
are equivalent.
If you want it to compare whether
$myRangeis a booleanfalse, use