Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP Math abs() function returns the absolute value (positive value) of the specified number. If the argument is of type float, the return type is also float, else it is integer.

Syntax

abs(number)

Parameters

number Required. Specify a number.

Return Value

Returns the absolute value (positive value) of the specified number.

Example:

In the below example, abs() function is used to return the absolute value (positive value) of the specified number.

<?php
echo abs(10)."\n";
echo abs(-10)."\n";
echo abs(5.5)."\n";
echo abs(-5.5)."\n";
?>

The output of the above code will be:

10
10
5.5
5.5

❮ PHP Math Functions