Here
are some of the inbuilt functions for numeric data types in php, that can be applied
to accomplish various numerical manupulations.
Source
Code:-
/**************************************************************/
<html>
            <head>
                        <title>phpinfo</title>
            </head>
            <body>
            <?php
                        $var=9/7;
                        echo "your variable
is = ".$var."<br />";
                        /*rounding up to 2
decimal places*/
                        echo "round the
number up to 2 decimals = ".round($var,2)."<br />";
                        /* ceil -> Returns
the smallest integer 
                        greater than or equal to
the specified argument */
                        echo "ceiling of
the number = ".ceil($var)."<br />";
                        /*floor -> Returns
the greatest integer less 
                        than or equal the specified argument*/
                        echo "floor of the
number = ".floor($var)."<br />";
                        /*prints the absolute
value*/
                        echo "absolute
value of 25-50 = ".abs(25-50)."<br />";
                        /*power function */
                        echo "5^3 =
".pow(5,3)."<br />";
                        /*square root function
*/
                        echo "square root
of 100 = ".sqrt(100)."<br />";
                        /* function to find
remainder */
                        echo "30%7 =
".fmod(30,7)."<br />";
                        /* random number
generator between specified range */
                        echo "a random
number b/w 100 and 200 = ".rand(100,200)."<br />";
            ?>
            </body>
</html>
/*************************************************************/
No comments:
Post a Comment