PHP Math

Back to ACP page

Table of Contents

PHP Math

<h2>PHP Math</h2> <p>PHP has a set of math functions that allows you to perform mathematical tasks on numbers.</p> <h4>PHP pi() Function</h4> <p>The pi() function returns the value of PI: </p> <?php echo(pi()); ?> <h4>PHP min() and max() Functions</h4> <p>The min() and max() functions can be used to find the lowest or highest value in a list of arguments: </p> <?php echo(min(0, 150, 30, 20, -8, -200)); echo(max(0, 150, 30, 20, -8, -200)); ?> <h4>PHP abs() Function</h4> <p>The abs() function returns the absolute (positive) value of a number: </p> <?php echo(abs(-6.7)); ?> <h4>PHP sqrt() Function</h4> <p>The sqrt() function returns the square root of a number: </p> <?php echo(sqrt(64)); ?> <h4>PHP round() Function</h4> <p>The round() function rounds a floating-point number to its nearest integer: </p> <?php echo(round(0.60)); echo(round(0.49)); ?> <h4>Random Numbers</h4> <p>The rand() function generates a random number: </p> <?php echo(rand()); ?>

Example 1

Result View Example

Document

Document in project

You can Download PDF file.

Reference