Home >>PHP Math Functions >PHP cos() Function
PHP cos()function is used to find the cosine of the given input number. It accepts only a single parameter $number which is the number whose cosine is to be found. The input value must be in radians. It returns a float value between -1 and 1 as output.
Syntax:
cos($number);
Parameter | Description |
---|---|
number | This is a required parameter. This parameter defines the given input number. |
Here is an example of cos() function in PHP:
<html> <body> <?php echo cos(1)."<br>"; echo cos(-1)."<br>"; ?> </body> </html>
Here is an another example of cos() function in PHP:
<html> <body> <?php $pi = M_PI; // M_PI is the value of PI(22/7) echo cos(0)."<br>"; echo cos($pi/3)."<br>"; echo cos($pi/4)."<br>"; echo cos($pi)."<br>"; echo cos(2*$pi)."<br>"; ?> </body> </html>