PI() : Constant Value
Contstant value equal to 3.1415926535898.
<?Php echo PI(); // Output is 3.14159265358983 echo M_PI; // Output is 3.1415926535898 ?> PI() with ROUND()Math function Round is used to manage decimal places
Values of M_PIecho M_PI_2; // Output is 1.5707963267949 // same as PI()/2 echo "<br>"; echo M_PI_4; // Output is 0.78539816339745 // same as PI()/4 echo M_1_PI; // Output is 1.5707963267949 // same as 1/PI() echo "<br>"; echo M_2_PI; // Output is 0.78539816339745 // same as 2/PI() rad2deg with PI()Converting Rading to degree by rad2deg() echo rad2deg(PI()); // Output is 180 echo "<br>"; echo rad2deg(PI()/2); // Output is 90 echo "<br>"; echo rad2deg(PI()/3); // Output is 60 echo "<br>"; echo rad2deg(PI()/4); // Output is 45 PI() with sin() cos()Decimal places Sin(), cos() and other trigonometric functions takes input in radian and give sin and cosine values of angles .
We used Round function to manage decimal places. Plotting of SIN & COS curves by using PHP GD function with deg2rad()
This article is written by plus2net.com team.
![]() |