This is my personal blog. The opinions and views I express are my own. The information I provide is on an as-is basis. I make no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this blog and will not be liable for any errors, omissions, or delays in this information or any losses, injuries or damages arising from its use.

PHP round, ceil and floor functions

I was working on a script this morning that required me to learn a little bit about PHP functions round, ceil and floor. The script below is just a simple demonstration of exactly what each does.

$answer = 5 * .256;  
echo "round function answer = ".round($answer)."<br/>"; 
echo "ceil function answer = ".ceil($answer)."<br/>"; 
echo "floor function answer =".floor($answer)."”;


This code returns the following:1.28
round function answer = 1
ceil function answer = 2
floor function answer = 1

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.