User Tools

Site Tools


uphp:functions:intval

This is an old revision of the document!


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 truncating the fractional component of the number

Parameters

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

Return Value

Integer value, or:

  • 0 on failure (for example, strings without a numeric in the leftmost characters)
  • 0 on empty arrays
  • 1 on non-empty arrays

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

Example

Convert the float '1.55' into an integer variable which has a value of 1:

<?
  $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 1

See Also

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

is_numeric() - Return 1 if the value is numeric (integer, float or numeric string)

ieee754toint() - Take a floating point value and return an IEEE-754 encoded integer (32 bit)

inttoieee754() - Take an IEEE-754 encoded integer (32 bit) and return a float

uphp/functions/intval.1489865617.txt.gz · Last modified: 2021/09/13 05:56 (external edit)