PHP Math Functions | rad2deg() | deg2rad()

Notes:

PHP Mathematical Constants & Functions:
- To perform mathematical calculations easily PHP provides various mathematical functions and constants

deg2rad(angleInDeg: Number):Number
- Converts the given angleInDeg to radians
Ex: echo deg2rad(180); // 3.1415926535898

rad2deg (angleInRad: Number):Number
- Converts the given angleInRad to degrees
Ex: echo rad2deg(M_PI); // 180

Example Code:
echo M_PI; // 3.1415926535898
echo rad2deg(M_PI); // 180
echo deg2rad(180); // 3.1415926535898
echo deg2rad(90); // 1.5707963267949
echo rad2deg(M_PI/2); // 90
echo deg2rad(360); // 6.2831853071796
echo rad2deg(2 * M_PI); // 360
echo rad2deg(6.2831853071796); // 360

Interview Questions:

1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a