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

COMPUTER SOFTWARE APPLICATION - CITS




           TASK 3: Using Switch statement

              1  Open the text editor
              2  Write the following codes
                 <html>
                 <head> <title>PHP </title></head>
                 <body>
                 <?php
                    $favcolor = “brown”;
                    switch ($favcolor)
                    {
                      case “red”:  echo “Your favorite color is red!”;
                         break;
                      case “blue”: echo “Your favorite color is blue!”;
                         break;
                      case “green”:  echo “Your favorite color is green!”;
                         break;
                      default:    echo “Your favorite color is neither red, blue, nor green!”;
                    }
                 ?>
                 <p>END</p>
                 </body>
                 </html>

              3  Save the program in C:\Apache24\htdocs in a folder with .php extension
              4  Run the Apache services from windows services
              5  Open the browser and type the following address
                 http://localhost/foldername/

              6  Click the php file to run  and verify the output























           TASK 4: Using the ? Operator
              1  Open the text editor

              2  Write the following codes
                    <?php



                                                           228

                               CITS : IT & ITES - Computer Software Application - Exercise 51
   238   239   240   241   242   243   244   245   246   247   248