Hello,
Bit confused here. Let's say I want to validate that a person is submitting a whole-number from ZERO to infinity...
I can validate that the submitted number is greater/equal-to 1 like this:
$v = "5";
if($v >= 1){
echo "Pass";
}
Two things I'm confused about...
1) How to make sure it's a whole number, ie: 2 or 3, not 2.5
2) How to deal with zeros.
When dealing with zeros, both of the following "Pass" even though $v is a word, not a number:
$v = 'word';
if($v >= 0){
echo "Pass";
}
if($v >= '0'){
echo "Pass";
}
To me, one of the above seems like it should look for the number zero or a greater number but they don't. They both echo "Pass".
How do you validate a number so as to make sure it is a whole-number ranging from 0 to infinity??? Oh, and also to make sure that an empty variable "" is not interpreted as a zero.
THANKS!