PHP heredoc example
April 25, 2011 12:57:46 Last update: April 25, 2011 12:58:08
In PHP, a heredoc string starts with
<<<followed immediately by an end tag and a new line, and ends by the end tag on its own line followed by a semi-colon.
<?php $v = "variable"; $s = <<<END_TAG Heredoc text starts with "<<<" followed immediately by the end tag (no space in between!). It ends with the end tag on its own line, starting at the first character of the line. The heredoc string behaves like it's double-quoted, with $v replacements.\n\n END_TAG; echo $s; ?>