The intval() function is used to get the integer value of a variable.
The intval() function returns the integer value of the variable var by using the specified base conversion (default is decimal). intval() cannot be used for object, otherwise an E_NOTICE error will be generated and 1 will be returned.
PHP 4, PHP 5, PHP 7
int intval ( mixed $var [, int $base = 10 ] )
Parameter description:
$var: The quantity value to be converted to integer.
$base: The base used for conversion.
If base is 0, the base used is determined by checking the format of var:
If the string includes the "0x" (or "0X") prefix, use hexadecimal (hex); otherwise,
If the string starts with "0", use octal; otherwise,
Decimal will be used.
Returns the integer value of var on success and 0 on failure. An empty array returns 0, a non-empty array returns 1.
The maximum value depends on the operating system. The maximum signed integer range on 32-bit systems is -2147483648 to 2147483647. For example, on such a system, intval('1000000000000') would return 2147483647. On a 64-bit system, the maximum signed integer value is 9223372036854775807.
It is possible for strings to return 0, although this depends on the leftmost character of the string.