If you want to genuinely know if a string is a valid representation of a true PHP integer type...
in_array($string, array_map('strval', range(PHP_INT_MIN, PHP_INT_MAX)), true)
However this is impossible to run as the set is too large (will not fit in memory in this case, if you loop instead it will take too many CPU cycles).
You can perhaps do a binary search with string comparison, however there are better ways.
The simplest being:
strlen($string) <= max(strlen((string)PHP_INT_MIN), strlen((string)PHP_INT_MAX)) && $string === (string)(int)$string
There are some other unusual ways to approach it such as:
is_int(array_keys([$string => null])[0])
You can also do string comparison but you'll still need to do things such as ctype_digit, check the length is reasonable (don't waste CPU before doing things like ctype_digit) and have some awkward handling for negative numbers.
Note that filter_var does not correctly assert that a string is genuinely the representation of a PHP integer. It will allow a leading + and surrounding whitespace.
Internally PHP uses the function "_zend_handle_numeric_str" for strict comparison but it doesn't directly expose this anywhere, hence the trick using the array keys (which does use it to convert any string that's a representation of a PHP integer to a PHP integer).
If you want binary safe conversion to and from PHP this is the approach to take.
Not everyone might want that and it might be a case of handling user input. filter_var isn't too bad for that and will be fairly safe in most cases for people new to PHP.
A length check, ctype_digit and then a check of converted value that it's in a range is also fairly solid for user input. More complex schemes might want trim or regex.
The problem with a lot of the answers here in that respect is that while the question is vague, the answers shouldn't be. If you're going to propose a solution you should be able to explain exactly what it will and wont expect. Without that there's no telling if an answer matches a question or is safe. The PHP manual does not always help because it doesn't explain all of the caveats for each of the relevant methods it supplies. Things such as ctype_digit and is_int are very reliable and easy to predit but the specifics of is_numeric, filter_var and juggling (+$var) or casting (intval/floatval) are poorly documented.
This is PHP fudge for you. It has a myriad number of schemas for interpreting strings as integers, with inconsistencies. The strictest method of validating an integer string is not directly exposed to the user.
is_int
simply tests whether a value is of integer data type. Therefore, it will return false for any string, regardless of whether it passes off as a representation of an integer. – Mahone