php method to change a negative number to a positive number: 1. Create a PHP sample file; 2. Enter "$a = -1;"; 3. Convert a negative number to a positive number through "abs($a);" Can.
#The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
php How to change a negative number to a positive one?
PHP Convert negative number to positive number
Function: abs()
$a = -1; $b = abs($a); echo $b; //输出 1
The abs() function is used to return the absolute value of a number.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to change negative numbers to positive in php. For more information, please follow other related articles on the PHP Chinese website!