C


Writing PHP Scripts

PHP scripts are plain text files that contain a mixture of PHP code and non-PHP content such as HTML. PHP interprets the script to produce a Web page to be sent as output to the client. The non-PHP content is copied to the output without interpretation. PHP code is interpreted and replaced by whatever output the code produces.

PHP begins interpreting a file in text copy mode. You can switch into and out of PHP code mode using special tags that signify the beginning and end of PHP code. PHP understands four types of tags, although some of them must be explicitly enabled if you want to use them. One way to do this is by turning them on in the PHP initialization file, php.ini. The location of this file is system dependent; on many Unix systems, it's found in /usr/lib or /usr/local/lib. On Windows, look in the Windows directory.

PHP understands the following tag styles:

  • The default style uses <?php and ?> tags:

     <?php print ("Hello, world."); ?> 

  • Short-open-tag style uses <? and ?> tags:

     <? print ("Hello, world."); ?> 

    This style also allows <?= and ?> tags as a shortcut for displaying the result of an expression without using a print statement:

     <?= "Hello, world." ?> 

    Short tags can be enabled with a directive in the PHP initialization file:

     short_open_tag = On; 

  • Active Server Page compatible style uses <% and %> tags:

     <% print ("Hello, world."); %> 

    This style also allows <%= and %> tags as a shortcut for displaying the result of an expression without using a print statement:

     <%= "Hello, world." %> 

    ASP-style tags can be enabled with a directive in the PHP initialization file:

     asp_tags = On; 

  • If you use an HTML editor that doesn't understand the other tags, you can use <script> and </script> tags:

     <script language="php"> print ("Hello, world."); </script> 



MySQL The definitive guide to using, programming, and administering MySQL 4. 1 and 5. 0
Mysql: the Definitive Guide to Using, Programming, and Administering Mysql 4.1 and 5.0
ISBN: B003A1PKHY
EAN: N/A
Year: 2004
Pages: 190
Authors: Paul Dubois

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net