What is deg2rad() in PHP?

The deg2rad() function in PHP converts a value in degrees to an equal value in radians.

Figure 1 below shows the mathematical representation of the deg2rad() function.

Figure 1: Mathematical representation of deg2rad() function

Syntax


float deg2rad(number)

Parameter

The deg2rad() function takes a numberdegree value as a parameter.

Return value

The deg2rad() function converts the degree value sent as a parameter to a value in radians.

Code

<?php
#180
echo("deg2rad(180): ");
echo (deg2rad(180));
echo(" Radians");
?>
<?php
#0
echo("deg2rad(0): ");
echo (deg2rad(0));
echo(" Radians");
?>
<?php
#-180
echo("deg2rad(-180): ");
echo (deg2rad(-180));
echo(" Radians");
?>

Free Resources