[php] What is the use of <<<EOD in PHP?

I am implementing node to PDF using drupal and tcpdf. In such case i am suppose to use this <<<EOD tag. If i didn't give this o/p is not perfect. I can't exactly get the purpose of <<<EOD.

Could anybody please explain the concept of this?

$html = <<<EOD
        <tr>
          <td>TEST</td>
        </tr>
EOD;

Thanks in advance....

This question is related to php syntax

The answer is


That is not HTML, but PHP. It is called the HEREDOC string method, and is an alternative to using quotes for writing multiline strings.

The HTML in your example will be:

    <tr>
      <td>TEST</td>
    </tr>

Read the PHP documentation that explains it.


there are four types of strings available in php. They are single quotes ('), double quotes (") and Nowdoc (<<<'EOD') and heredoc(<<<EOD) strings

you can use both single quotes and double quotes inside heredoc string. Variables will be expanded just as double quotes.

nowdoc strings will not expand variables just like single quotes.

ref: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc