Printing Here Documents


Printing "Here" Documents

Here's another printing option: you can also create "here" documents, which cause echo or print to display everything it reads until it encounters an end token you specify (usually END), which must be placed at the very beginning of a line. You can see what this looks like in Example 1-3, phphere.php.

Example 1-3. Printing a here document
 <HTML>     <HEAD>         <TITLE>             Displaying here Documents         </TITLE>     </HEAD>     <BODY>         <H1>             Displaying here Documents         </H1> <?php echo <<<END This example uses "here document" syntax to display all the text until the ending token is reached. END; ?>         <BR>         <BR>         <IMG src="/books/1/265/1/html/2/php-power-white.gif">     </BODY> </HTML> 

The result of this here document appears in Figure 1-7.

Figure 1-7. Displaying a here document.




    Spring Into PHP 5
    Spring Into PHP 5
    ISBN: 0131498622
    EAN: 2147483647
    Year: 2006
    Pages: 254

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