Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources


The PHP Math cos() function returns trigonometric cosine of an angle (angle should be in radians).

Syntax

cos(number)

Parameters

number Required. Specify the angle in radian.

Return Value

Returns the trigonometric cosine of an angle.

Example:

In the example below, cos() function is used to find out the trigonometric cosine of an angle.

<?php
echo cos(pi()/6)."\n";
echo cos(pi()/4)."\n";
echo cos(pi()/3)."\n"; 
?>

The output of the above code will be:

0.86602540378444
0.70710678118655
0.5

❮ PHP Math Functions

5