Web Analytics

PHP abs() Function

Math FunctionPHP 4+

The abs() function returns the absolute value of a number.

Syntax

abs(int|float $num): int|float

Parameters

Parameter Type Description
$num int|float The number to get absolute value of

Return Value

Returns the absolute value of the number.

Try It Online

Output
Click Run to execute your code

Common Use Cases

  • Distance calculations
  • Finding differences
  • Ensuring positive values