The importance of predefined mathematical functions for web programming as well as software design can not be overemphasized. PHP provides some very simple yet powerful math functions to undertake this task. The math functions in PHP can handle values within the range of integer and float types. Good thing is, the math functions are part of the PHP core. There is no installation needed to use these functions.

Some of the important math functions used in PHP are described below:

* abs()*: This functions returns the absolute value of a number. It takes a single variable as its parameter and returns it absolute value. For example:

1 2 3 4 5 |
<?php echo(abs(6.7) . "<br />"); echo(abs(-3) . "<br />"); echo(abs(3)); ?> |

The above code will return the absolute values of the three variables, which would be 6.7, 3 and 3.

** ceil(x)**: This functions returns the value of a number rounded upwards to the nearest integer. For example:

1 2 3 4 5 |
<?php echo(ceil(0.60) . "<br />"); echo(ceil(0.40) . "<br />"); echo(ceil(5) . "<br />"); ?> |

The above code would return the ceiling values of the three variables which would be 1, 1 and 5.

Similarly, ** floor()** function would return the value of a number rounded downwards to the nearest integer.

* acos()*: This functions returns the arccosine of a number. For example:

1 2 3 4 5 |
<?php echo(acos(0.64) . "<br />"); echo(acos(0) . "<br />"); echo(acos(-1) . "<br />"); ?> |

The above code would return the cosine values of the three variables which would be *0.876298061168*, *1.57079632679* and *3.14159265359*.

Similarly there are ** asin()** and

** exp()**: This function returns the value of exponential value of its arguments. For example:

1 2 3 4 |
<?php echo(exp(1) . "<br />"); echo(exp(-1) . "<br />"); ?> |

The above code would return the exp values of its arguments which would be *2.718281828459045* and *0.36787944117144233* respectively.

** max()**: This function would return the number with the highest value of two specified numbers. For example:

1 2 3 |
<?php echo(max(5,7) . "<br />"); ?> |

The above code would return 7, the maximum of the two numbers.

Similarly, there is ** min()** function which return the minimum of the two numbers.

These and many other math functions are extensively utilized in PHP programming and serve to make the mathematical calculations very simple, precise and easy.

Looking for a quality hosting service? here are a few I suggest.

BlueHost | HostGator | Media Temple

BlueHost | HostGator | Media Temple

Ali has been an entrepreneur in web, video and related technologies. Having worked with many business across the globe, Ali stands truly a great pillar in the business working with him.