Home >Backend Development >PHP Problem >Implementation method of converting php to positive number
The implementation method of converting php to positive number: first create a PHP sample file; then define a negative number; then use the "abs($a);" method to convert the specified negative number into a positive number; finally use echo output conversion The result is enough.
Recommendation: "PHP Video Tutorial"
PHP negative number to positive number
Function: abs ()
$a = -1; $b = abs($a);
abs() function returns the absolute value of a number.
Syntax
abs(x)
Parameters
x Required. A number.
Description
Returns the absolute value of parameter x. If the parameter x is a float, the return type is also a float, otherwise an integer is returned (because float usually has a larger value range than an integer).
The above is the detailed content of Implementation method of converting php to positive number. For more information, please follow other related articles on the PHP Chinese website!