In PHP, there are two primary numeric data types: Integers and Floats.
PHP provides automatic data type conversion. So, if you assign an integer value to a variable, the type of that variable will automatically be an integer. Then, if you assign a string to the same variable, the type will change to a string!
An integer is a number without any decimal part.
PHP has built-in functions to check if the type of a variable is integer:
is_int()is_integer() - alias of is_int()is_long() - alias of is_int()<?php $x = 5985; var_dump(is_int($x)); // Returns bool(true) ?>
A float is a number with a decimal point or a number in exponential form.
To check if a number is a float, you can use is_float() or is_double().
is_numeric()The is_numeric() function can be used to find whether a variable is a number or a numeric string. It is widely used in web forms to validate user inputs.