Math Function in PHP:Part 1

Introduction

The PHP math functions are used to handle values within the range of integer and float types. In this article I am describing some of the PHP math functions.

PHP Abs() function

It returns the absolute value of a number.

Syntax

abc (number)


Parameters in Abs
function

It contains one parameter.
 

Parameter Description
number It specifies number.

Example of Abs function

<?
php

echo (abs(4.5)."</br>");

echo (abs(4.55)."</br>");

echo (abs(-8)."</br>");

echo (abs(4)."</br>");

echo (abs(0.0)."</br>");

?>

Output

abs-math-function-in-php.jpg

PHP Acos() function


It is used in PHP to find the arccosine of a number as a numeric value (value between 0 and PI radians) .

Syntax

acos (number)


Parameters in
Acos function

It contain one parameter.
 

Parameter Description
number It specifies a numeric value( range -1 to 1).

Example of Acos function

<?
php

echo (acos(0.15)."</br>");

echo (acos(0)."</br>");

echo (acos(1)."</br>");

echo (acos(-1)."</br>");

echo (acos(2)."</br>");

?>

Output

acos-math-function-in-php.jpg

PHP Asin() function


It is used in PHP to find the arcsine of a number as a numeric (value -PI/2 and PI/2 radians).

Syntax

acos(number)


Parameters in
Asin function

It contains one parameter.
 

Parameter Description
number It specifies a numeric value( range -1 to 1).

Example of Asin function

<?
php

echo (asin(0.15)."</br>");

echo (asin(0)."</br>");

echo (asin(1)."</br>");

echo (asin(-1)."</br>");

echo (asin(2)."</br>");

?>

Output

 asin-math-function-in-php.jpg

Up Next
    Ebook Download
    View all
    Learn
    View all