title: PHP heredoc parse error
body: <p>This produces output page OK</p>
  
  <pre><code>$mystring = "&lt;&lt;&lt;EOT";
  </code></pre>
  
  <p>Replacing it with the following produces</p>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected $end in file.php on line 737</p>
  </blockquote>
  
  <pre><code>$mystring = &lt;&lt;&lt;EOT
     This is some PHP text.
     It is completely free
     I can use "double quotes"
     and 'single quotes',
     plus $variables too, which will
     be properly converted to their values,
     you can even type EOT, as long as it
     is not alone on a line, like this:
  EOT;
  </code></pre>
  
  <p>Any ideas as to what is causing the parser to choke?</p>
  
  <p>I'm using PHP 4.4.7.</p>
  
  <p>It is only on one file that this behaviour happens all others follow the PHP defined functionality.</p>
  
  <p>What I am trying to recitify is what could be possibly wrong in the proceding lines so that the PHP parser shows in this failure.</p>
  
  <p>John</p>
  
  <p>changed file contents to :-</p>
  
  <pre><code>&lt;?php
  
  $mystring = &lt;&lt;&lt;WHATEVER
     This is some PHP text.
  WHATEVER;
  ?&gt;
  </code></pre>
  
  <p>result =</p>
  
  <p>Parse error: syntax error, unexpected $end in file.php on line 5</p>
  
  <p>Any clues</p>
  
  <p>EDIT</p>
  
  <p>original error was to do with <code>T_ENCAPSED_AND_WHITESPACE</code> this can be caused with jQuery for example "<code>if(x == y){$('#my_image').hide():}</code>" is within the heredoc the bigram "{$ will start the parser looking for php variable for substitution.</p>
  
  <p>EDIT</p>
  
  <p>2 good responses.</p>
  
  <p>1) Ch4m3l3on - "<code>&lt;?php</code>" vs "<code>&lt;?</code>" handling. </p>
  
  <p>2) The Disintegrator - <code>&lt;q&gt;</code>had a similar problem with a stupid program that insisted in putting the BOM in a utf-8 file (ignoring preferences)<code>&lt;/q&gt;</code>.</p>
  
  <p>EDIT</p>
  
  <p>1) Replacing all content with a single  block didn't fix the problem or give any other pointers.</p>
  
  <p>2) No BOM (Byte Order Mark), pity as this or similar majic characters would have explained all symptoms perfectly.</p>