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

Unit 2: Language Basics



                                                                                                  Notes


                        Create a PHP program using special characters in PHP.


            Self Assessment

            Choose the correct answer:
               1.  PHP is a ................. scripting language.
                 (a)  client-side                (b)  server-side
                 (c)  both (a) and (b)           (d)  none of these
               2.  In PHP the names of user-defined classes and functions as well as built-in constructs and
                 keywords are case-insensitive.
                 (a)  True                       (b)  False
               3.  In PHP ................. is used to separate tokens in PHP source file.
                 (a)  variables                  (b)  semicolon
                 (c)  white space                (d)  operators
               4.  A ................. is used to mark the end of a statement in PHP.
                 (a)  variables                  (b)  semicolon
                 (c)  white space                (d)  operators
               5.  Which one is not a data type?
                 (a)  String                     (b)   Boolean
                 (c)  Objects                    (d)  Public

            2.2.5 Here Documents

            The heredoc string structure is a method of including larger strings inside your code. You can use
            it to include content of any length. To create a heredoc, you use a special operator that is made
            up of three left brackets (<<< ). The syntax is as follows:
            $longString = <<< termination_marker
            any amount of content

            termination_marker;
            For instance:
            $longFellowNot = <<< End_of_verse

            This short poem
            May not fill a tome,
            But it serves to show

            How it is that heredoc goes.
            End_of_verse;
            Anything between the termination markers is preserved, included all white space, quote marks,
            and special characters. The last carriage return before the closing termination marker is omitted,
            so if you want one, you should leave a blank line after the end of the content and before the
            termination marker.



                                             LOVELY PROFESSIONAL UNIVERSITY                                    31
   32   33   34   35   36   37   38   39   40   41   42