How to change negative numbers to positive in php

藏色散人
Release: 2023-03-14 18:52:01
Original
3396 people have browsed it

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.

How to change negative numbers to positive in php

#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
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template