(PHP 4, PHP 5, PHP 7, PHP 8)
abs —Absolute value
num
The numeric value to process
The absolute value ofnum
. If the argumentnum
is of typefloat, the return type is alsofloat, otherwise it isint (asfloat usually has a bigger value range thanint).
Version | Description |
---|---|
8.0.0 | num no longer accepts internal objects which support numeric conversion. |
Example #1abs() example
<?php
var_dump(abs(-4.2));
var_dump(abs(5));
var_dump(abs(-5));
?>
The above example will output:
float(4.2)int(5)int(5)