Does php’s is_int function return false for negative numbers because integers in php are unsigned, or is there other behaviour that I’m missing? I’m trying to check if something is a whole number, and I don’t want to rely on that behaviour of is_int (for the first part of the test) if it’s doing something different.
Clarification: I know that is_int returns false for negative numbers, but I’m asking why because of this behaviour: var_dump(intval("-10")) prints int(-10), and var_dump(intval("10")) prints int(1), so both negative and positive values are considered integers, yet is_int("-10") returns false.
EDIT: Ok, sorry everyone, I got quite a bit confused about the behaviour of is_int and integers in general. I was thinking of it acting on a string with contents like “-10” when what I need is is_numeric on a string, or is_int on an integer itself. Thanks for the help.
It doesn’t:
Probably, it isn’t a number to begin with:
If so, try out is_numeric(), which is designed for strings.