← All built-ins / intval()

intval()

intval(mixed $number): int

Parameters

NameTypeDescription
$vmixedvalue to convert

Return value

The integer value: floats truncate, strings parse their leading number (0 when not numeric).

Example

echo intval("42"), " ", intval(3.99), " ", intval("12abc"), " ", intval(true);
42 3 12 1

See also

floatval()strval()is_numeric()