PHP deg2rad() Function
Example
Convert degrees to radians:
<?php
echo deg2rad("45") . "<br>";
echo deg2rad("90") . "<br>";
echo deg2rad("360");
?>
Run example »
Definition and Usage
The deg2rad() function converts a degree value to a radian value.
Tip: To convert a radian value to a degree value, look at the rad2deg() function.
Syntax
deg2rad(number);
Parameter | Description |
---|---|
number | Required. Specifies the degree to convert |
Technical Details
Return Value: | The radian equivalent of number |
---|---|
Return Type: | Float |
PHP Version: | 4+ |
More Examples
Example 1
Convert a degree into its radian equivalent:
<?php
$deg = 180;
$rad = deg2rad($deg);
echo "$deg degrees is equal to $rad radians.";
?>
Run example »
PHP Math Reference