PHP Math

PHP offers a variety of functions to perform mathematical operations on numbers.

Tutorials dojo strip

PHP pi() Function

The pi() function returns the value of Pi:

PHP

PHP min() and max() Functions

The min() and max() functions can be used to find the smallest or largest value in a set of arguments:

PHP

PHP abs() Function

The abs() function returns the absolute (positive) value of a number:

PHP

PHP sqrt() Function

The sqrt() function returns the square root of a number:

PHP

PHP round() Function

The round() function rounds a floating-point number to the nearest integer:

PHP

Random Numbers

The rand() function generates a random number:

PHP

To generate a random number within a specific range, you can include optional minimum and maximum parameters. For example, to get a random integer between 50 and 150:

PHP

Tutorials dojo strip