abs
Description
Syntax
abs(
int|float $num
): int|floatParameters
num
The numeric value to process
Return
The absolute value of num.
If the argument num is of type float, the return type is also float, otherwise it is int (as float usually has a bigger value range than int).
Examples
1 · num · int · negative
<? $num = -1234; $return = abs($num); var_dump($return);
int(1234)
2 · num · int · positive
<? $num = 1234; $return = abs($num); var_dump($return);
int(1234)
3 · num · float · negative
<? $num = -12.34; $return = abs($num); var_dump($return);
float(12.34)
4 · num · float · positive
<? $num = 12.34; $return = abs($num); var_dump($return);
float(12.34)