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

Unit 2: Language Basics



            Introduction                                                                          Notes

            PHP is a general-purpose server-side scripting language originally designed for web development
            to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source
            document and interpreted by a web server with a PHP processor module, which generates the
            web page document. It also has evolved to include a command-line interface capability and can
            be used in stand alone graphical applications. PHP can be deployed on most web servers and as a
            stand alone interpreter, on almost every operating system and platform free of charge. A competitor
            to Microsoft’s Active Server Pages (ASP) server-side script engine and similar languages, PHP is
            installed on more than 20 million websites and 1 million web servers.
            The main implementation of PHP is now produced by the PHP Group and serves as the de facto
            standard for PHP as there is no formal specification. PHP is free software released under the PHP
            License which is incompatible with the GNU General Public License (GPL) due to restrictions on
            the usage of the term PHP.

            2.1 Lexical Structure


            Computer languages, like human languages, have a lexical structure. A source code of a PHP
            script consists of tokens. Tokens are atomic code elements. In PHP language, we have comments,
            variables, literals, operators, delimiters and keywords.
            Embedding
            PHP code is inserted into an HTML page between the start and end tags <? and ?>. The word
            PHP follows the start tag.
                html code

                <?php
                  ... PHP code goes here
                ?>
                more html code

            Case Sensitivity
               •  The names of user-defined classes and functions as well as built-in constructs and keywords
                 are case-insensitive.
               •  Variables are case sensitive.

            Comments
            Comments are used by humans to clarify the source code. All comments in PHP follow the
            #character.

            <?php
            # comments.php
            # Navneet

            # ZetCode 2009
            echo “This is comments.php script\n”;
            ?>

            Everything that follows the # character is ignored by the PHP interpreter.



                                             LOVELY PROFESSIONAL UNIVERSITY                                    23
   24   25   26   27   28   29   30   31   32   33   34