is_numeric to validate number in phpWe can use is_numeric function in PHP to check if a number or variable is numeric or not. This function we can use to check user inputs of a form on a component where we expect only numeric data can be entered. This function can check and take care of decimal and exponential numbers also. Here is the syntax
is_numeric(number);The above checking will return true or false based on the value stored on number. Let us try some examples. The output of each type of checking is given at its right side within comments.
echo is_numeric(12.35);// Output 1
We can also use FILTER_VALIDATE_INT php filter to validate integer.