PHP abs() - Math Functions

What is abs Function?

Explanation

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

Syntax:


abs(x)

In the above syntax "x" is a number that is float which returns a float,or an integer value.

Example :


<?php
echo(abs(-6.2));
print "<br>";
echo(abs(7));
print "<br>";
echo(abs(-3));
?>
Result :

6.2
7
3

In the above example the absolute value of the negative numbers are displayed.

PHP Topics


Ask Questions

Ask Question