Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
PHP abs() Function
Definition and Usage
The abs() function is an in-built function in PHP iterpreter. This function accepts any number as argument and returns a positive value, disregarding its sign. Absolute value of any number is always positive.
This function always returns positive number.
Syntax
abs( mixed $num)
Parameters
| Sr.No | Parameter & Description |
|---|---|
| 1 |
num This parameter stores a value whose absolute value is to be obtained. |
Return Values
PHP abs() function returns absolute value of num. If data type of num is float, return type is also float.For integer parameter, return type is integer.
PHP Version
This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.
Example
<?php $num="Hello"; echo "String: " . $num . "
"; echo "absolute value : " . abs($num) . "
"; ?>
Output
This will produce the following result −
String: Hello absolute value : 0
Advertisements
