PHP sin()
Published May 18, 2023Updated Jun 6, 2025
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():
<?phpecho(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:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PHP on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours