Example 1 — Sine of Common Angles
Use radian constants to try sin() with well-known angles.
<?php
echo sin(0), PHP_EOL;
echo sin(M_PI_2), PHP_EOL;
echo round(sin(deg2rad(30)), 2), PHP_EOL; How It Works
- sin(0) is 0.
- M_PI_2 is 90 degrees in radians, and its sine is 1.
- deg2rad(30) converts 30 degrees to radians.
- round() cleans up tiny floating-point errors and shows 0.5.

