Archive for the ‘Programming’ Category
round () in php
Wednesday, November 5, 2008 23:41 No CommentsThe PHP function round () is used to round numbers up or down based on their value (Any decimal .5 or above is rounded up, anything under .5 is rounded down.) by default it will round to the nearest whole number < ?php echo (round(0.70) . ""); echo (round(0.50) . ""); echo (round(0.20) . ""); [...]
floor() in Php
Wednesday, November 5, 2008 23:27 2 Commentsfloor() is the opposite of Ceil(). It rounds down a floating-point number to the next-lowest integer, no matter what the value of the floating-point number is. Integer on success; FALSE on error Example #1 floor() example < ?php echo floor(4.3); // 4 echo floor(9.999); // 9 echo floor(-3.14); // -4 ?>
ceil() in php
Wednesday, November 5, 2008 23:16 No CommentsThe ceil() function Returns an integer that is the next larger than the float used as the argument. In essence, it rounds up a floating-point number to an integer, no matter what the value of the floating-point integer is. It doesn’t round down. Example#1 ceil() example < ?php echo ceil(4.3); // 5 echo ceil(9.999); // [...]
multiple catch block in php
Saturday, November 1, 2008 9:56 No CommentsSome time there is a need to catch more than one exception..In such a situation, we can associate more than one catch statement with a try, When an exception is thrown, the exception handlers are searched in order for an appropriate match. The first handler that yields a match is executed. After executing the handler, [...]
throw Exception in php
Friday, October 31, 2008 9:52 No Commentstry { doExchange(); throw new Exception(“D’oh!”); echo “hai”; } catch (Exception $except) { logger.error(“doExchange failed”, e); } In that example, PHP enters the “try” block and starts executing code. When it hits the line “throw new Exception”, it will stop executing the “try” block, and jump to the “catch” block. Here it checks each exception [...]
