PHP intval() Function

PHP intval() Function


The intval() function is an inbuilt function in PHP which returns the integer value of a variable.

Syntax:

int intval ( $var, $base )

Parameters: This function accepts two parameters out of which one is mandatory while the other one is optional. Parameters are described below:

  • $var: It is a mandatory parameter serves as the variable which needs to be converted to its integer value.
  • $base: It ia a optional parameter specifies the base for conversion of $var to its corresponding integer. If $base is not specified.