Computer >> Computer tutorials >  >> Programming >> PHP

cos() function in PHP


The cos() function Returns the cosine of a number. A numeric value between -1 and 1 is Returned representing the cosine of the angle.

Syntax

cos(num)

Parameters

  • num − The specified value in radians

Return

The cos() function Returns cosine of a number in float. A numeric value between -1 and 1 is Returned representing the cosine of the angle.

Example

<?php
   echo(cos(1) . "<br>");
   echo(cos(-1));
?>

Output

0.54030230586814<br>0.54030230586814

Example

Let us see another example −

<?php
   echo(cos(0));
?>

Output

1