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

COMPUTER SOFTWARE APPLICATION - CITS





                   $pattern = “/c.t/”;



                   if (preg_match($pattern, $string))
                   {
                         echo “Pattern found in the string.”;
                   }
                   else

                   {
                         echo “Pattern not found in the string.”;
                   }
                 ?>

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











           V  Matching any digit using ‘\d’

              1  Open the text editor
              2  Write the following codes
                          <html >
                 <head>

                     <title> Matching any digit using ‘\d’ </title>
                 </head>
                 <body>
                        <?php
                   $string = “abc123xyz”;
                   $pattern = “/\d/”;



                   if (preg_match($pattern, $string))
                   {




                                                           297

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