abs()


int/float abs ( int/float $number )

Description

abs() returns the absolute value of a given number

※ available F/W version : all

Parameters

Return values

Returns the absolute value of the number. If the argument is float, it returns float, and if the argument is integer, it returns integer

Example

<?php
$ret1 = abs(-10.11);
$ret2 = abs(10.11);
$ret3 = abs(-10);
$ret4 = abs(10);

echo "ret = $ret1\r\n";  // OUTPUT: ret = 10.11
echo "ret = $ret2\r\n";  // OUTPUT: ret = 10.11
echo "ret = $ret3\r\n";  // OUTPUT: ret = 10
echo "ret = $ret4\r\n";  // OUTPUT: ret = 10
?>

See also

None

Remarks

This function is identical to the PHP group’s abs() function.