Example 1 — Convert common angles
Convert a few well known angles and round the results to four decimals.
<?php
echo round(deg2rad(180), 4) . PHP_EOL;
echo round(deg2rad(90), 4) . PHP_EOL;
echo round(deg2rad(45), 4) . PHP_EOL; How It Works
- deg2rad(180) is the same as pi, which is 3.14159...
- deg2rad(90) is pi divided by 2.
- deg2rad(45) is pi divided by 4.
- round(..., 4) keeps four decimal places so the output is short and clean.

