PHP intval() Function

PHP Variable Handling Reference : Return the integer value of different variables

Definition and Usage

The intval() function returns the integer value of a variable.

Syntax

intval(variable, base);

Parameter Values

Parameter Description
variable Required. Specifies the variable to check
base Optional. Specifies the base to use for the conversion. Only has effect if variable is a string. Default base is 10

Technical Details

Return Value: The integer value of the variable on success, 0 on failure. An empty array will return 0, and a non-empty array will return 1
Return Type: Integer
PHP Version: 4.0+
PHP Changelog: PHP 5.1: When an object is passed to variable, it throws E_NOTICE and returns 1

❮ PHP Variable Handling Reference