Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP abs() Function

PHP abs() Function

PHP Math Reference Manual PHP Math Reference Manual

Example

Return the absolute value of different numbers:

"); echo(abs(-6.7) . "
"); echo(abs(-3) . "
"); echo(abs(3)); ?>

Run Example »


Definition and Usage

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


Syntax

abs(

number

);

Parameters Description
number Required. Specifies a number. If the number is a float, the returned type is also a float, otherwise it is returned as an integer.

Technical Details

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

PHP Math Reference Manual PHP Math Reference Manual