Search w3schools.com:

SHARE THIS PAGE

PHP abs() Function


PHP Math Reference Complete PHP Math Reference

Definition and Usage

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

Syntax

abs(x)

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


Example

<?php
echo(abs(6.7) . "<br />");
echo(abs(-3) . "<br />");
echo(abs(3));
?>

The output of the code above will be:

6.7
3
3


PHP Math Reference Complete PHP Math Reference

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]