PHP abs() Function
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
Enjoying these tutorials?