How can I do an if statement for greater than or equal to 0 but not empty? AND less than X?
At the moment if $score
is empty then it considers it zero.
<?php if ($score >= 0 AND $score < $passmark) { ?>
How can I do an if statement for greater than or equal to 0 but not empty? AND less than X?
At the moment if $score
is empty then it considers it zero.
<?php if ($score >= 0 AND $score < $passmark) { ?>
Add a special case for zero:
if ($score === 0 || ($score > 0 && $score < $passmark))
$score === 0
will fail for false, 0.0, "", "0", [], null
; and these values will fail $score > 0
check. If you want to extend your definition of empty to include any of these values add a special case just as you did for 0
.