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

COMPUTER SOFTWARE APPLICATION - CITS





                      <?php
                             $string = “Hello World”;

                 if (preg_match(“/hello/i”, $string)) {
                      echo “Match found!”;
                 } 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












           II  m (multiline mode) modifier
              1  Open the text editor
              2  Write the following codes
                             <html >
                    <head>

                         <title> m (multiline mode) modifier </title>
                    </head>
                    <body>
                           <?php

                                $string = “First line\nSecond line”;
                 if (preg_match(“/^Second/m”, $string)) {
                          echo “Match found!- multiline mode “;
                 } else {
                         echo “No match found!”;
                 }

                 // Output: Match found!
                                 ?>




                                                           303

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