PHP/String/here document

Материал из Web эксперт
Перейти к: навигация, поиск

Concatenation with a here document

   <source lang="html4strict">

<? $html = <<< END

  • END . $listItem . "
  • </div>";

    print $html; ?>

     </source>
       
      
    


    Defining a here document

       <source lang="html4strict">
    
    

    <? print <<< END Line 1:

      Line 2
    

    END; ?>

     </source>
       
      
    


    Interpolating in a here document

       <source lang="html4strict">
    
    

    <? $page_title = "Menu"; $meat = "pork"; $vegetable = "vvv"; print <<<MENU <html> <head><title>$page_title</title></head> <body>

    • $meat
    • $meat
    • $meat with $vegetable

    </body> </html> MENU; ?>

     </source>
       
      
    


    More here documents

       <source lang="html4strict">
    
    

    <? print <<< PARSLEY line 1: line line line PARSLEY; print <<< DOGS line line! DOGS; ?>

     </source>
       
      
    


    Printing HTML with a here document

       <source lang="html4strict">
    
    

    <? print <<< HTML There are 5 left.

    HTML; ?> </source>