PHP Function Reference

PHP rad2deg() Function



The PHP rad2deg() function is used to convert an angle in radians to an angle in degrees.

Syntax

rad2deg(number)

Parameters

number Required. Specify an angle in radians to convert.

Return Value

The degree equivalent of an angle in radians.

Example:

In the example below, rad2deg() function is used to convert an angle in radians to an angle in degrees.

<?php
echo "rad2deg(PI()/6) returns: ".rad2deg(PI()/6)."\n";
echo "rad2deg(PI()/3) returns: ".rad2deg(PI()/3)."\n";
echo "rad2deg(PI()/2) returns: ".rad2deg(PI()/2)."\n";
echo "rad2deg(M_PI) returns: ".rad2deg(M_PI)."\n";
echo "rad2deg(M_PI_2) returns: ".rad2deg(M_PI_2)."\n";
echo "rad2deg(M_PI_4) returns: ".rad2deg(M_PI_4)."\n";
?>

The output of the above code will be:

rad2deg(PI()/6) returns: 30
rad2deg(PI()/3) returns: 60
rad2deg(PI()/2) returns: 90
rad2deg(M_PI) returns: 180
rad2deg(M_PI_2) returns: 90
rad2deg(M_PI_4) returns: 45

❮ PHP Math Reference