Home >>PHP Math Functions >PHP acos() Function

PHP acos() Function

PHP acos() Function

PHP acos() function is used to find the arc cosine value of a given input number in radians. It is the complementary function of cos(). The parameter passed in it should be a number in the range of -1 to 1.

Syntax:

   acos($number);

Parameter Values

Parameter Description
number This is a required parameter. This parameter defines a number in range -1 to 1.

Here is an example of acos() function in PHP:

<html>
<body>

<?php

echo acos(0.54)."<br>";
echo acos(-0.54)."<br>";

?>

</body>
</html>
Output:
1.000359217395
2.1412334361948

Here is an another example of acos() function in PHP:

<html>
<body>

<?php

echo acos(0)."<br>";
echo acos(-1)."<br>";
echo acos(1)."<br>";
echo acos(2);  // value should be in the range of 1 to -1.

?>

</body>
</html>
Output:
1.5707963267949
3.1415926535898
0
NAN

No Sidebar ads