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

COMPUTER SOFTWARE APPLICATION - CITS



              {
                  validateEmail(“john.doe@example.com”);
                  echo “Valid email address.<br/>”;

                  validateEmail(“invalid_email_address”);
                  echo “This line will not be reached due an exception will be thrown.<br/>”;
              }
              catch (CustomException $e)
              {
                  // Catch the custom exception and handle it
                  echo $e->errorMessage() . “<br/>”;
              }
                       ?>
              </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 7: Using Iterators
           I  Using foreach loop
              1  Open the text editor
              2  Write the following codes

                       <html >
              <head>
                  <title> Iterators </title>
              </head>

              <body>
                <?php
              $numbers = [1, 2, 3, 4, 5];
              foreach ($numbers as $number)
              {
                 echo $number . “ “;

              }


                                                           325
 CITS : IT & ITES - Computer Software Application - Exercise 60  CITS : IT & ITES - Computer Software Application - Exercise 60
   335   336   337   338   339   340   341   342   343   344   345