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

COMPUTER SOFTWARE APPLICATION - CITS
















           IV  x (extended) modifier
              1  Open the text editor
              2  Write the following codes
                             <html >
                    <head>
                         <title> x (extended) modifier </title>
                    </head>
                    <body>
                           <?php
                               $pattern = “
                                         /
                                        ^               # Start of the string
                                        \d{3}           # Match exactly 3 digits
                                        -               # Match a hyphen
                                        \d{4}           # Match exactly 4 digits
                                        $               # End of the string
                                        /x
                 “;

                 $string = “123-4567”;
                 if (preg_match($pattern, $string)) {
                          echo “Match found!- extended modifier”;
                 “;
                 } else {
                         echo “No match found!”;
                 }
                 // Output: Match found!
                                 ?>
                    </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









                                                           305

                               CITS : IT & ITES - Computer Software Application - Exercise 58
   315   316   317   318   319   320   321   322   323   324   325