PHP abs() Function
Definition and Usage
The abs() function returns the absolute value of a number.
Syntax
abs(x)
Parameter | Description |
---|---|
x | Required. A number. |
Description
returns the parameter x absolute value. If the parameter x If the type of the variable is float, the returned type is also float, otherwise it returns integer (because float usually has a larger range of values than integer).
Example
<?php echo(abs(6.7)); echo(abs(-3)); echo(abs(3)); ?>
Output:
6.7 3 3