Check if input is a number in PHP 7.1.x


The is_int() doesn’t tell you if the string is actually a number, instead it returns false.

If you convert your string numeric into an int and then do this, only then will it work. But there is a problem with this approach, while converting string to an int, we use intval(). This converts strings to 0's.


So the best way to find out whether a variable is an actual numeric or not is to use this php function.