PHP - Math cos() Function
The PHP Math cos() function is used to return 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 below example, 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