What is and how to use the '<<<END_JAVASCRIPT' string?
<p>I found this code snippet for php:</p>

<pre><code>$sJavascript = &lt;&lt;&lt;END_JAVASCRIPT

var callback = arguments[arguments.length-1], 
nIntervalId; 

function checkDone() {
  if( window.MY_STUFF_DONE ) {
    window.clearInterval(nIntervalId); // stop polling
    callback("done"); // return "done" to PHP code
  }
}

nIntervalId = window.setInterval( checkDone, 50 ); // start polling
END_JAVASCRIPT;

$sResult = $session-&gt;execute_async(array(
  'script' =&gt; $sJavascript,
  'args' =&gt; array(),
 ));
</code></pre>

<p>What is that 'END_JAVASCRIPT' string(?) and how and when should be use? 
P.S. I tried to run this snippet but I get a parse error in PHP ('unexpected $end'). </p>

<p><strong>UPDATE:</strong>
The reason I was getting the parse error is that I indented the code (including the closing identifier 'END_JAVASCRIPT'). The PHP <a href="http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc" rel="nofollow">heredoc</a> documentation contains the following warning:</p>

<blockquote>
  <p><em>It is very important to note that the line with the closing identifier must contain no other characters, except <strong>possibly</strong> a semicolon (;). That means especially that the identifier <strong>may not be indented</strong>, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system.</em></p>
</blockquote>
