Page 268 - Computer Software Application TP - Volume 1
P. 268

COMPUTER SOFTWARE APPLICATION - CITS




              decbin($number): Converts a decimal number to a binary string.

              dechex($number): Converts a decimal number to a hexadecimal string.
              hexdec($hex_string): Converts a hexadecimal string to a decimal number.
              Other Mathematical Functions:
              pi(): Returns the value of pi.

              deg2rad($number): Converts degrees to radians.
              rad2deg($number): Converts radians to degrees.
              fmod($x, $y): Returns the floating-point remainder of x divided by y.


           TASK 8: Display random numbers
              •  Open the text editor
              •  Write the following codes
                     <?php
                                 echo rand().”<br/>”;//returns a pseudo-random integer    between 0 and getrandmax().
                                         echo rand(5, 15). “<br/>”;//returns random number between 5 and 15 (inclusive)
                                         var_dump(random_int(100, 999));
                         echo “<br/>”;
                                         var_dump(random_int(-1000, 0));// Get a cryptographically secure, uniformly selected
                 integer function for situations requiring strong randomness.
                         echo “<br/>”;
                                        $bytes = random_bytes(5);
                                        var_dump(bin2hex($bytes));// Get cryptographically secure random bytes
                                ?>
              •  Save the program in C:\Apache24\htdocs in a folder with .php extension
              •  Run the Apache services from windows services
              •  Open the browser and type the following address

                 http://localhost/foldername/
              •  Click the php file to run and verify the output































                                                           253

                               CITS : IT & ITES - Computer Software Application - Exercise 53
   263   264   265   266   267   268   269   270   271   272   273