Page 133 - Open Soource Technologies 304.indd
P. 133

Unit 5: Strings



            Regular expression: A regular expression follows a strict syntax to describe patterns of characters.   Notes
            PHP has two sets of functions that use regular expressions: one set supports the Perl Compatible
            Regular Expression (PCRE) syntax, and the other supports the POSIX extended regular expression
            syntax.
            strpos( ): The strpos( ) function finds the first occurrence of a small string in a larger string.

                          1.  Develop a PHP program to compare two strings word by word.

                          2.  Develop a PHP program to change an uppercase string into lower case.


            5.11 Review Questions

               1.  What is the meaning of string? How does it use in PHP?
               2.  How do we quote the string constants in PHP? Explain with example.
               3.  What are the heredocuments? Why does it used?
               4.  What we do to print strings? Explain the functions.
               5.  What are the format modifiers?
               6.  What are the type specifiers? Discuss the printf () type specifiers.
               7.  How do we access the individual character?
               8.  How do we clean the strings? Which functions are used?

               9.  How do we compare the strings? Explain with example.
              10.  How do we perform manipulation and searching on strings?
              11.  Explain the regular expressions used in PHP.
            Answers to Self Assessment

               1.  (a)    2.  (c)       3.  (a)      4.  (a)        5.  (b)
               6.  (a)    7.  print ( )   8.  syntax   9.   occurrence

            5.12 Further Reading




                          Core Web Application Development with PHP and MySQL, by Marc
                          Wandschneider.




                          http://www.w3schools.com/php/php_string.asp

















                                             LOVELY PROFESSIONAL UNIVERSITY                                   127
   128   129   130   131   132   133   134   135   136   137   138