``````<?Php
echo deg2rad(0); // Output is 0
echo "<br>";
echo "<br>";
echo deg2rad(180); // Output is 3.1415926535898
echo "<br>";
echo deg2rad(270); // Output is 4.7123889803847
?>``````
Syntax
``deg2rad(X);``
X is the number representing angular value in degree.

We can use round() to remove extra decimal places.
``````<?Php
echo round(deg2rad(90),2); // Output  is 1.57
?>``````

Decimal places Sin(), cos() and other trigonometric functions takes input in radian so while using if we are using data in degree then we have to convert them first and then use with Sin() , Cos() etc.
``````<?Php
echo sin(deg2rad(90)); // Output  is 1
?>
``````
Let us try few more examples
``````<?Php
echo sin(deg2rad(0)); // Output  is 0
echo "<br>";
echo round(sin(deg2rad(180))); // Output  is 0
echo "<br>";
echo sin(deg2rad(270)); // Output  is -1
echo "<br>";
echo cos(deg2rad(0)); // Output  is 1
echo "<br>";
echo cos(deg2rad(180)); // Output  is -1
echo "<br>";
echo tan(deg2rad(45)); // Output  is 1
?>``````
Plotting of SIN & COS curves by using PHP GD function with deg2rad()

Subscribe to our YouTube Channel here

## Subscribe

* indicates required
Subscribe to plus2net

plus2net.com