Table of Contents

Syntax

number abs(mixed $value)

(PHP 4, PHP 5)

$value A numeric value (either a float or an integer).
RETURNS The absolute value of the numeric argument ($value).

What it Does

Calculates the absolute value of the numeric argument and returns it. So if you pass it a value of -5, the result would be 5.

Example

// demonstrate the abs function
echo 'Abs(-123) = ' . abs(-123);