Home  >  Article  >  Backend Development  >  How to use abs function in php

How to use abs function in php

藏色散人
藏色散人Original
2019-05-23 10:33:213536browse

Usage of abs function in php: [abs(number)]. The abs function is used to return the absolute value of the specified parameter. If the parameter is of float type, the returned type is also float, otherwise it returns the Integer type.

How to use abs function in php

#php How to use abs function?

(Recommended tutorial: php video tutorial)

The function of the abs() function is to return the absolute value of a number. The syntax is abs(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).

abs() function function: The function of abs() function is to return the absolute value of a number.

Syntax:

abs(number)

Parameters:

number must be a number.

Description: Return the absolute value of the parameter. If the parameter is float, the returned type is also float. If the parameter is int, the return type is int. If the parameter is a string string, 0 is returned;

php abs() function usage example:

<?php
$i = -100;
$j = abs($i);
$a = 6.7;
$b = abs($a);
$k = "hello world";
$c = abs($k);
echo $j."*****".$b."*****".$c;
?>

Output:

100*****6.7******0

Related recommendations: php training

The above is the detailed content of How to use abs function in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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