Home >>PHP Math Functions >PHP rad2deg() Function

PHP rad2deg() Function

PHP rad2deg() Function

PHP rad2deg() function is used to convert a given radian input value to a equivalent degree value. It accepts only a single parameter $number that is of float type which is the given angle to be converted in Radians. To convert a degree value back to a radian value we use the deg2rad() function.

Syntax:

  rad2deg($number);

Parameter Values

Parameter Description
number This is a required parameter. This parameter defines a radian value to convert.

Here is an example of rad2deg() function in PHP:

<html>
<body>

<?php

echo rad2deg(2*M_PI)."<br>";
echo rad2deg(M_PI)."<br>";
echo rad2deg(M_PI_2)."<br>";
echo rad2deg(M_PI_4)."<br>";

?>

</body>
</html>
Output:
360
180
90
45

Here is another example of rad2deg() function in PHP:

<html>
<body>

<?php

echo M_PI." = ".rad2deg(pi())."°<br>";
echo M_PI_2." = ".rad2deg(pi()/2)."°<br>";
echo M_PI_4." = ".rad2deg(pi()/4)."°<br>";

?>

</body>
</html>
Output:
3.1415926535898 = 180°
1.5707963267949 = 90°
0.78539816339745 = 45°