PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<Mathacos>
Last updated: Mon, 16 Jul 2012

abs

(PHP 3, PHP 4, PHP 5)

abs -- 绝对值

说明

number abs ( mixed number )

返回参数 number 的绝对值。如果参数 numberfloat,则返回的类型也是 float,否则返回 integer(因为 float 通常比 integer 有更大的取值范围)。

例子 1. abs()

<?php
$abs
= abs(-4.2); // $abs = 4.2; (double/float)
$abs2 = abs(5);  // $abs2 = 5; (integer)
$abs3 = abs(-5);  // $abs3 = 5; (integer)
?>



<Mathacos>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST