PHP abs() Function

❮ PHP Math Reference

Example

Return the absolute value of different numbers:

<?php
echo(abs(6.7) . "<br>");
echo(abs(-6.7) . "<br>");
echo(abs(-3) . "<br>");
echo(abs(3));
?>
Try it Yourself »

Definition and Usage

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


Syntax

abs(number);

Parameter Values

Parameter Description
number Required. Specifies a number. If the number is of type float, the return type is also float, otherwise it is integer

Technical Details

Return Value: The absolute value of the number
Return Type: Float / Integer
PHP Version: 4+

❮ PHP Math Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.