Table of Contents

intval

WMPRO, WMMINI FW >= 1.0 WMMEGA FW >= 2.0

Return the integer value of a number or string

Description

int intval ( mixed $value )

Return the integer value by rounding

Parameter

$value: A string with a leading number, or a number (int or float)

Return Values

Integer value, or:

The maximum value possible is a signed integer in the range -2147483648 to 2147483647.

Example

Convert the float '1.55' into an integer which has a value of '2'

<?
  $f=1.55;
  $i=intval($f);
  print("The integer value of ".$f." is ".$i);
?>

The above example will output:

The integer value of 1.550000 is 2

See Also

floatval() - Return the float value of a number or string

strval() - Return the string equivalent of a number

is_numeric() - Check if a value is numeric (int, float or numeric string)

ieee754toint() - Convert a float value to an IEEE-754 encoded integer (32 bit)

uPHP Variable Types and Limits

Note

In firmware versions released before 8/14/17 this function returned the integer value by truncating the fractional component of the number (it did not round up or down):

WMPRO, WMMINI FW < 1.1068 WMMEGA FW < 2.1068