I am completely clueless over validating 0 as integer. I am trying to validate user input in the range of 0 to 2. The user input is given to a function like this:
(int)mysql_real_escape_string(filter_var(trim($_POST['score']), FILTER_SANITIZE_NUMBER_INT))
Now inside the function, I even checked it to be exactly 0 like this:
if ($score === 0) echo 'something';
That worked. However... in the validation process, it's not working, probably because the FILTER_VALIDATE_INT filter does not validate 0 as an integer, even though I did everything for it to accept it as an integer. Values 1 and 2 are accepted by this:
filter_var($score, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0, 'max_range'=> 2 )))
Anyone can tell me why this validation fails for the value 0?
EDIT: found out 0 is handled as empty for some reason.
Lolyou guys both speak excellent english... Sometimes I wonder if statik is to pro for you ray? Im mega newb,so I have no idea.. Just seems like statik always has an answer, and he seems leet
I'm far away from excellent English, but thank you, that feels nice from a native speaker.
Yes, Statik always has an answer and he is a great coder, no doubt about that, I'm just usually looking for something else, not what he thinks and I meant that if I was Russian and I could ask him in our native language, he would give me the exact answer I'm looking for.