PHP abs()Function

PHP Math 参考手册PHP Math Reference Manual

Examples

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));
?>

Run Example »

Definition and Usage

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


Syntax

abs(number);

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

Technical Details

Return value: numberThe absolute value of.
Return type: Float / Integer
PHP Version: 4+


PHP Math 参考手册PHP Math Reference Manual Other Extensions