Example 1 — Basic cos() usage
This example finds the cosine of a few common angles in radians.
<?php
echo cos(0) . PHP_EOL;
echo cos(M_PI) . PHP_EOL;
echo round(cos(M_PI / 3), 4) . PHP_EOL;
echo round(cos(1), 4) . PHP_EOL; How It Works
- cos(0) is exactly 1.
- cos(M_PI) is -1 because pi radians is 180 degrees.
- M_PI / 3 is 60 degrees, and its cosine is 0.5.
- cos(1) is about 0.5403, where 1 means 1 radian, not 1 degree.

