php-library.com
 -Home
  
Documentation
-PHP Manual>
Table of contents
Copyright
Preface
Getting started
Language reference
Security
Features
Function reference
Zend API
PHP API:Interfaces for extension writers
FAQ
Appendixes

-Pear Manual>
Table of contents
Copyright
Preface
About this manual
Structure of manual
I) About PEAR
 1. Introduction
 2 Installation
 3 Support
 4 Coding standards
 5 Contributing
 6 FAQ
II) Developer Guide
 7 Introduction
 8 PEAR's meaning for developers
 9 Contributing your own code
 10 The package definition file package.xml
 11 Releasing a package
 12 Supporting PEAR development
III) Core components
 13 PEAR base classes
 14 PPM classes
IV) Packages
 15 Authentication
 16 Benchmarking
 17 Caching
 18 Configuration
 19 Console
 20 Database
 21 Date & time
 22 Encryption
 23 File formats
 24 File System
 25 HTML
 26 HTTP
 27 Images
 28 Logging
 29 Mail
 30 Math
 31 Networking
 32 Numbers
 33 Payment
 34 PEAR
 35 PHP
 36 Science
 37 System
 38 Text
 39 XML
V) PECL packages
 I. Advance PHP debugger
 II. PHP bytecode compiler
 III. Imagick
 IV. KADM5
 V. Radius
 VI. Paradox file access
 VII. Satellite CORBA client extention
 VIII. PostgreSQL session save handler
 IX. Soap
 X. SPPLUS payment system
 XI. Net_Gopher
 XII. oggvorbis

-PHP-GTK Manual>
Table of contents
Copyright
Preface
PHP-GTK userguide
I) Introduction to PHP-GTK
 1. What is PHP-GTK?
 2. What is PHP?
 3. What is GTK+?
 4. Acknowledgements
II) Getting started
 1. Getting the lastest version
 2. Installing PHP-GTK under Windows
 3. Installing PHP-GTK under Unix
 4. How to use PHP-GTK
III) Basic elements
 1. Widgets & containers
 2. Signals & callbacks
PHP-GTK tutorials
I) Hello world tutorial
PHP-GTK reference
I) GTK classes
II) GDK clasesse
III) GTK enums
IV) GDK enums
V) Glade classes
VI) Scintilla classes
Appendix
I) PHP-GTK credits
II) PHP-GTK documentation credits
III) GNU free documentation license
IV) Symbolic names for keys in PHP-GTK
 
More stuff here
 -Contact Us
 -Links
 -
Sitemap
 
 
 
 

Chapter 5. Basic syntax

Escaping from HTML

When PHP parses a file, it simply passes the text of the file through until it encounters one of the special tags which tell it to start interpreting the text as PHP code. The parser then executes all the code it finds, up until it runs into a PHP closing tag, which tells the parser to just start passing the text through again. This is the mechanism which allows you to embed PHP code inside HTML: everything outside the PHP tags is left utterly alone, while everything inside is parsed as code.

There are four sets of tags which can be used to denote blocks of PHP code. Of these, only two (<?php. . .?> and <script language="php">. . .</script>) are always available; the others can be turned on or off from the php.ini configuration file. While the short-form tags and ASP-style tags may be convenient, they are not as portable as the longer versions. Also, if you intend to embed PHP code in XML or XHTML, you will need to use the <?php. . .?> form to conform to the XML.

The tags supported by PHP are:

Example 5-1. Ways of escaping from HTML

1.  <?php echo("if you want to serve XHTML or XML documents, do like this\n"); ?>

2.  <? echo ("this is the simplest, an SGML processing instruction\n"); ?>
    <?= expression ?> This is a shortcut for "<? echo expression ?>"
    
3.  <script language="php">
        echo ("some editors (like FrontPage) don't
              like processing instructions");
    </script>

4.  <% echo ("You may optionally use ASP-style tags"); %>
    <%= $variable; # This is a shortcut for "<% echo . . ." %>

The first way, <?php. . .?>, is the preferred method, as it allows the use of PHP in XML-conformant code such as XHTML.

The second way is not available always. Short tags are available only when they have been enabled. This can be done via the short_tags() function (PHP 3 only), by enabling the short_open_tag configuration setting in the PHP config file, or by compiling PHP with the --enable-short-tags option to configure. Even if it is enabled by default in php.ini-dist, use of short tags are discouraged.

The fourth way is only available if ASP-style tags have been enabled using the asp_tags configuration setting.

Note: Support for ASP-style tags was added in 3.0.4.

Note: Using short tags should be avoided when developing applications or libraries that are meant for redistribution, or deployment on PHP servers which are not under your control, because short tags may not be supported on the target server. For portable, redistributable code, be sure not to use short tags.

The closing tag for the block will include the immediately trailing newline if one is present. Also, the closing tag automatically implies a semicolon; you do not need to have a semicolon terminating the last line of a PHP block.

PHP allows you to use structures like this:

Example 5-2. Advanced escaping

<?php
if ($expression) { 
    ?>
    <strong>This is true.</strong>
    <?php 
} else { 
    ?>
    <strong>This is false.</strong>
    <?php 
}
?>
This works as expected, because when PHP hits the ?> closing tags, it simply starts outputting whatever it finds until it hits another opening tag. The example given here is contrived, of course, but for outputting large blocks of text, dropping out of PHP parsing mode is generally more efficient than sending all of the text through echo() or print() or somesuch.

 
Network Sites
Domain registration : Register domain name from $5.95
Domain name registration or transfer domain name from $5.95/yr. Includes comprehensive free services such as URL/Email forwarding.
Website hosting : cheap web hosting from $8.95
Website hosting service for single or multiple domain names for as low as $2 per domain.
Cheap domain name registration by cheap domain registrar
Domain name registration and transfer service by Cheap Domain Name Registrar.

 


www.PHP-library.com