Sunday, September 18, 2011

PHP here document (also called a here-document, a heredoc, a hereis, here-string or here-script)

Using heredoc in PHP


<?php
echo <<<EOT

    <h1>This will display as an h1</h1>
    <p>I can use "double quotes"</p>
    <h1>and 'single quotes',
    <p>plus $variables too, which will
    be properly converted to their values,
    you can even type EOT.</p>

    <p>Make sure your opening EOT has no spaces after it,
    and the closing EOT has no spaces infront of it!</p>


 EOT;
 ?>

0 comments:

Post a Comment

Delicious Digg Stumbleupon Favorites