PHP/Math/abs

Материал из Web эксперт
Перейти к: навигация, поиск

abs( ) function returns the absolute value of the parameter

   <source lang="html4strict">

<?

   abs(50); // 50
   abs(-12); // 12

?>

 </source>
   
  


Calling the Built-in abs() Function

   <source lang="html4strict">

<html> <head><title>Calling the Built-in abs() function</title></head> <body>

<?php

   $num = -321;
   $newnum = abs( $num );
   print $newnum;

?>

</body> </html>

 </source>
   
  


You can either send a floating-point number or an integer to abs( )

   <source lang="html4strict">

<?

   abs(50.1); // 50.1
   abs(-12.5); // 12.5

?>

 </source>