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

COMPUTER SOFTWARE APPLICATION - CITS



           EXERCISE 53 : Demonstratethe Writing  to the browser,

                                      Getting input from forms, Output buffering,
                                      Common math,  Random numbers, File

                                      upload,  File  download,  Environment

                                      variables



            Objectives

           At the end of this exercise you shall be able to
           •  write content to the browser using PHP
           •  check common math and random number functions in PHP
           •  upload download from server using PHP.

           Requirements

           Tools/Materials
           •   Computer/Laptop with latest configuration       •  PHP
           •   Operating system: windows 10 or 11              •  Text editor
           •  Apache web server                                •  Web browser


           Procedure

           TASK 1: Writing to the browser
              1  Open the text editor
              2  Write the following codes
                              <html>
                              <body>
                               <?php
                         // Example with echo
                         echo “Hello, world!”;

                         // Example with print
                         print “This is also displayed”;


                         // Example with printf
                         $name = “Alice”;
                         printf(“Welcome, %s!”, $name);


                         // Example with sprintf
                         $message = sprintf(“You have %d unread messages.”, 3);
                         echo $message;

                         // Declare variable and store the string
                         $output = “A computer science portal”;
                         echo “<script>console.log(‘Value of variable: “ . $output . “’ );</script>”;
                         ?>



                                                           244
   254   255   256   257   258   259   260   261   262   263   264