Javatpoint Logo
Javatpoint Logo

PHP abs() function

The abs() function returns absolute value of given number. It returns an integer value but if you pass floating point value, it returns a float value.

Syntax:

Name Description Return type
number Numeric value Float/integer
PHP math abs function

Example1

Output:

The value of abs(-4.2) is: 4.2
The value of abs(5) is: 5
The value of abs(-5) is: 5

Example 2:

Output:

123

Example 3

Output:

The array [0] value is = 1 
The array [1] value is = 2 
The array [2] value is = 4 
The array [3] value is = 7.3 
The array [4] value is = 105 

Note: array_map() is used to change all negative number of an array.


Next TopicPHP Math





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA