See the PHP documentation on is_numeric . It talks about everything that is allowed, and it is more than is_float and is_int .
It is also important to note that is_int only works with things of type integer, which means that string representations are not allowed. This is a common problem when verifying that form input is an integer. You must use filter_var or something from the filter family with the filter FILTER_VALIDATE_INT . For floats, use FILTER_VALIDATE_FLOAT .
Also, if the reason you are trying to check for an integer is to check the parameter as an int, then in PHP 7 you can do this:
function foo(int $i) {
PHP 7 has two different conversion modes to int; this answer explains it a little more.
Note that this is probably not what you want if you are checking the contents of a form element. Use the filter_var solution for this.
Levi morrison
source share