ABS in PHP Example. Using this program we can print the absolute which means a nonnegative number. On a number line, a number’s absolute value is its distance from zero. f(x) = |x| is the absolute value function. The positive value of the input is the output.

<?php

echo(abs(-5.1));

?>

Output:

5.1

## abs() Function in Php

The abs() function is a built-in PHP function that returns the absolute (positive) value of an integer. In PHP, the abs() function is equivalent to what we call modulus in mathematics. A negative number’s modulus or absolute value is positive. ABS() calculates the absolute value of a given value. An absolute value is the distance of a number on the number line from 0 without taking into account whatever direction the number is pointing from zero. As a result, the absolute value of a number is always non-negative.