PI() : Constant Value

<?Php
echo PI(); // Output is 3.14159265358983
echo M_PI; // Output is 3.1415926535898
?>
Syntax
PI();
Contstant value equal to 3.1415926535898.

PI() with ROUND()

Math function Round is used to manage decimal places

<?Php
echo round(PI(),2); // Output is 3.14
echo "<br>";
echo round(PI()/2,2); // Output is 1.57
echo "<br>";
echo round(M_PI_4,2); // Output is 0.79 
?>

Values of M_PI

echo 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 .
<?Php
echo round(sin(pi()),2);// Output  is 0
echo "<br>";
echo sin(pi()/2); // Output  is 1
echo "<br>";
echo cos(pi()); // Output  is -1
echo "<br>";
echo round(cos(PI()/2),2); // Output  is 0
?>
We used Round function to manage decimal places.

Plotting of SIN & COS curves by using PHP GD function with deg2rad()

Math Functions SIN() function rad2deg() function
Subhendu Mohapatra — author at plus2net
Subhendu Mohapatra

Author

🎥 Join me live on YouTube

Passionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.



Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2025   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer