abs()

Published Apr 20, 2023
Contribute to Docs

The abs() function returns the absolute value of the argument.

Syntax

$result = abs(n);

Where n is the number to find the absolute value of.

Codebyte Example

Using abs() to return the absolute value of -6.5:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn PHP on Codecademy