PHP Math Functions | round() | ceil() | floor()

Notes:

PHP Mathematical Constants & Functions:
- To perform mathematical calculations easily PHP provides various mathematical functions and constants.

ceil(value:number):number
- It rounds the given value to the upper nearest integer
Ex:
echo ceil(2.9); // 3

floor(value:number):number
- It rounds the given value to the lower nearest integer
Ex:
echo floor(2.5); // 2

round(value:number):number
- Rounds the given value to the nearest integer
- for 0,1,2,3,4 returns lower nearest integer
- for 5,6,7,8,9 returns upper nearest integer
Ex:
echo round(2.9); // 3

Interview Questions:

1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a