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

Parameter

$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 array
  • 1 on non-empty array

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 '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 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

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