Recent changes Random page
GAMING
Technology
 
Gaming
Entertainment
Science Fiction
Biggest wikis
Hobbies
Music
See more...

Abs

from PHPWiki - the free guide to PHP.

Jump to: navigation, search

[edit] Description

abs returns the absolute value of input. The type of the returned value depends on the type of input. It will be will float if the type of input is also float. Otherwise the return value will be of type integer.

Note that if the type of input isn't float or integer the value will be converted to integer.

[edit] Parameters

number abs (mixed number)

[edit] Parameter Infos

Parameter PHP Version Type
abs 4 or 5 returns mixed (integer, float)
number 4 or 5 mixed (integer, float, string, array)


[edit] Examples

[edit] Example 1:

<?php
 echo abs(-3);   // integer
 echo abs(3);    // integer
 echo abs(-2.4); // float
?>

[edit] Output

3
3
2.4


For more details on this function, visit its entry in the php manual.
Rate this article:
Share this article: