Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
math
degrees
radians
communitycreator

What is deg2rad() in PHP?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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");
?>

RELATED TAGS

php
math
degrees
radians
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring