sin()

digital6476489273's avatar
Published May 18, 2023
Contribute to Docs

The sin() function returns the sine of an angle given in radians.

Syntax

sin(angle)

The sin() function takes only one parameter, angle, an angle in radians of type float. The function returns the sine of the angle as a float value.

Example

Use sin() to return the sine of the pi angle given in radians, using the function pi():

<?php
echo(sin(pi()));
?>

The example will result in the following output:

1.2246467991474E-16

The result is close to but not equal to zero due to machine precision.

Codebyte Example

The codebyte example below uses the sin() function to return the sine of the 540 angle given in degrees. Then, it uses the deg2rad() function to parse from degrees to radians:

Code
Output
Loading...

All contributors

Contribute to Docs

Learn PHP on Codecademy