pTutorial

New way to learn PHP function

PHP abs() Function

Syntax


abs(number);

 
Parameter Description
number Number can be integer or float

Definition

It Returns the absolute value of number as the same variable type.

Usage

It is used to find the absolute value of any number. For example absolute value of -85 is 85.

Example of abs function


<?php



echo abs(-38);



var_dump( abs(-38) );



?>

We can directly pass the integer or float into the abs function or store on a variable, pass the variable into the abs function.

More example of abs function


<?php



$a = -780.25;



echo abs($a);



?>

In this example first store the value on the variable and after that pass the variable into the abs function as shown above.

QUOTES OF THE DAY

A single death is tragedy, a million death is a static.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER