Funkce PHP abs() .
Příklad
Vraťte absolutní hodnotu různých čísel:
<?php
echo(abs(6.7) . "<br>");
echo(abs(-6.7) . "<br>");
echo(abs(-3) . "<br>");
echo(abs(3));
?>
Definice a použití
Funkce abs() vrací absolutní (kladnou) hodnotu čísla.
Syntax
abs(number);
Hodnoty parametrů
Parameter | Description |
---|---|
number | Required. Specifies a number. If the number is of type float, the return type is also float, otherwise it is integer |
Technické údaje
Návratová hodnota: | Absolutní hodnota čísla |
---|---|
Typ vrácení: | Plovoucí / Celé číslo |
Verze PHP: | 4+ |
❮ PHP Math Reference