Home > PHP > Function > Variable handling > intval()

intval()

intval - Get the integer value of a variable

Syntax

int intval (mixed $var, int $base)

Arguments

  • var - The scalar value being converted to an integer
  • base - The base for the conversion

Description

Returns the integer value of var, using the specified base for the conversion (the default is base 10). intval() should not be used on objects, as doing so will emit an E_NOTICE level error and return 1.

Version

PHP 4, 5

Return value

The integer value of var on success, or 0 on failure. Empty arrays and objects return 0, non-empty arrays and objects return 1.