PHP deg2rad() Function
The PHP deg2rad() function is used to convert an angle in degrees to an angle in radians.
Syntax
deg2rad(number)
Parameters
number |
Required. Specify an angle in degrees to convert. |
Return Value
The radian equivalent of an angle in degrees.
Example:
In the example below, deg2rad() function is used to convert an angle in degree to an angle in radian.
<?php $x = 30; $y = 60; $z = 90; echo "deg2rad($x) returns: ".deg2rad($x)."\n"; echo "deg2rad($y) returns: ".deg2rad($y)."\n"; echo "deg2rad($z) returns: ".deg2rad($z)."\n"; ?>
The output of the above code will be:
deg2rad(30) returns: 0.5235987755983 deg2rad(60) returns: 1.0471975511966 deg2rad(90) returns: 1.5707963267949
❮ PHP Math Reference