PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP Math - acos() Function

The PHP Math acos() function returns arc cosine of a value. The return value will be in the range 0 through 𝜋. In special cases it returns the following:

  • If the argument is NAN or its absolute value is greater than 1, then the result is NAN.

Note: acos() is the inverse of cos().




number Required. Specify the value.

Return Value

Returns the arc cosine of the value.


In the example below, acos() function is used to find out the arc cosine of a given value.

echo "acos(-1) = ".acos(-1)."\n";
echo "acos(-0.5) = ".acos(-0.5)."\n";
echo "acos(0) = ".acos(0)."\n";
echo "acos(0.5) = ".acos(0.5)."\n";
echo "acos(1) = ".acos(1)."\n";
echo "acos(2) = ".acos(2)."\n";
echo "acos(NAN) = ".acos(NAN)."\n";

The output of the above code will be:

acos(-1) = 3.1415926535898
acos(-0.5) = 2.0943951023932
acos(0) = 1.5707963267949
acos(0.5) = 1.0471975511966
acos(1) = 0
acos(2) = NAN
acos(NAN) = NAN

❮ PHP Math Functions