Posts

Showing posts with the label PHP Math functions

PHP Math Functions

 Php has some predefined math functions to calculation mathematics problems. Some of them are listed below: 1) Php pi() function: <?php echo(pi()); // returns 3.1415926535898 ?> 2) Php min() & max() function:  <?php echo(min(0, 150, 30, 20, -8, -200));  // returns -200 echo(max(0, 150, 30, 20, -8, -200));  // returns 150 ?> 3) Php abs() function:  <?php echo(abs(-6.7));  // returns 6.7 ?> 4) Php sqrt() function:  <?php echo(sqrt(64));  // returns 8 ?> 5) Php round() function:  <?php echo(round(0.60));  // returns 1 echo(round(0.49));  // returns 0 ?> 6) Php rand() function:  <?php echo(rand()); ?> For complete math functions you can visit w3schools.com website.