Problem with heredoc statement
<p>I am trying to replace the HTML code with a heredoc statement. However, I am getting a parse error in the last line.I am sure that I have not left any leading space or indentation on the heredoc closing tag line.Following is <strong>a part of</strong> the code:</p>

<pre><code>$table = &lt;&lt;&lt;ENDHTML
    &lt;div style="text-align:center;"&gt;
    &lt;table border="0.5" cellpadding="1" cellspacing="1" style="width:50%; margin-left:auto; margin-right:auto;"&gt;
    &lt;tr&gt;
    &lt;th&gt;Show I.D&lt;/th&gt;
    &lt;th&gt;Show Name&lt;/th&gt;
    &lt;/tr&gt;
    ENDHTML;
    while($row = mysql_fetch_assoc($result)){
         extract($row);
         $table .= &lt;&lt;&lt;ENDHTML
         &lt;tr&gt;
          &lt;td&gt;$showid2 &lt;/td&gt;
          &lt;td&gt;$showname2&lt;/td&gt;
         &lt;/tr&gt;
    ENDHTML;     
    }
    $table .= &lt;&lt;&lt;ENDHTML
    &lt;/table&gt;
    &lt;p&gt;&lt;$num_shows Shows&lt;/p&gt;
    &lt;/div&gt;
    ENDHTML; 
    echo $table;
    ?&gt;
</code></pre>

<p>Where is the problem?
I have a related question in addition to above. As a coding practice, is it better to use PHP code throughout or is it better to use a heredoc syntax. I mean, while in PHP mode, the script bounces back and forth between the HTML and PHP code. 
So, which is the preferred method?</p>
