I currently have a form containing an input:
<input type="text" name="score" id="score" value="" />
Criteria: I need the value in this input to be below 40 and a positive integer or zero.
Having read up on php.net about is_int() and is_numeric(). It advises using is_numeric() with form fields as these are always numeric strings.
I want to check if the value meets the above criteria but don't follow how I would do this in the above situation.
<?php
$score = $_POST['score'];
if(is_numeric($score) && $score <= 40){
// Do good stuff
} else {
// Don't do good stuff
} ?>
My issue with the above is that floats would pass this test and without using something like (int) $score I can't use is_int() which then negates the is_numeric check.
Am I missing something here?
is_numericand then cast toint?