PHP cos()Functions

PHP Math 参考手册PHP Math Reference Manual

Examples

Returns the cosine of different numbers:

<?php
echo(cos(3) . "<br>");
echo(cos(-3) . "<br>");
echo(cos(0) . "<br>");
echo(cos(M_PI) . "<br>");
echo(cos(2*M_PI));
?>

Run example »

Definition and Usage

The cos() function returns the cosine of a number.

Note: cos()The function returns a value between -1 and 1, representing the cosine of the angle.


Syntax

cos(number);

Parameter Description
number Required. Specifies a number.

Technical Details

Return value: numberthe cosine of
Return type: Float
PHP version: 4+


PHP Math 参考手册PHP Math Reference Manual Other Extensions