Elective Courses
Course Recommendation:
PHP cos() Function
Definition and Usage
The cos() function returns the cosine of a number.xSyntax
cos( | ) |
---|---|
x | Parameter |
Description
cos() returns the parameter x Cosine Value x The unit is radians.
Tips and Notes
Note:The value returned by cos() is between -1 and 1.
Example
In this example, we will calculate the cosine of different values:
<?php echo(cos(3)); echo(cos(-3)); echo(cos(0)); echo(cos(M_PI)); echo(cos(2*M_PI)); ?>
Output:
-0.9899924966004454 -0.9899924966004454 1 -1 1