In the last article, we introduced "Using stripos() in php to obtain the position of the first occurrence of a string". This article will take you to take a look. abs()
Function. In the daily use of php
, we may need to obtain the absolute value of a variable. At this time, we can use the built-in function abs()
function in php
, this article first takes you to take a look at the syntax of the function:
abs ( mixed $number )
$number: the numeric value to be processed.
Return value : The absolute value of $number. If the parameter $number is float, the return type is also float, otherwise it returns integer (because float usually has a larger value range than integer).
Code example:
<?php $abs = abs(-4.2); $abs2 = abs(5); $abs3 = abs(-5); echo $abs."<br>"; echo $abs2."<br>"; echo $abs3."<br>"; ?>
输出: 4.2 5 5
Recommendation: 《2021 PHP interview questions summary (collection)》《 php video tutorial》
The above is the detailed content of Using abs() to obtain the absolute value of parameters in php. For more information, please follow other related articles on the PHP Chinese website!