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

COMPUTER SOFTWARE APPLICATION - CITS





           III  Matching any character from a set
              1  Open the text editor
              2  Write the following codes
                             <html >
                    <head>
                         <title> Matching any character from a set </title>
                    </head>
                    <body>
                      <?php
                         $string = “The color is blue.”;
                         $pattern = “/[aeiou]/”;  // Matches any vowel


                         if (preg_match($pattern, $string))
                         {
                                 echo “The string contains a vowel.”;
                         }


                    ?>
                 </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











           IV  Matching any single character using the dot wildcard
              1  Open the text editor
              2  Write the following codes
                          <html >

                 <head>
                     <title> Matching any single character using the dot wildcard </title>
                 </head>
                 <body>
                        <?php

                   $string = “cat”;




                                                           296

                               CITS : IT & ITES - Computer Software Application - Exercise 58                                                         CITS : IT & ITES - Computer Software Application - Exercise 58
   306   307   308   309   310   311   312   313   314   315   316