Heredoc 不适用于以下代码
$html = <<<HTML
<video width="$width" height="$height" controls preload autoplay >
<source src="$video_url_direct" type="video/mp4" />
<object id="flowplayer" width="$width" height="$height" data="$player_url" type="application/x-shockwave-flash">
<param name="allowfullscreen" value="true" />
<param name="wmode" value="transparent" />
<param name="flashvars" value='config={"clip":"$video_url", "plugins": {"controls": {"autoHide" : false} }}' />
</object></video>
HTML;
Run Code Online (Sandbox Code Playgroud)
我也可以使用heredoc作为flashvars值(即另一个heredoc内的heredoc)。
后面有一个空格<<<HTML:
$html = <<<HTML
here---^
Run Code Online (Sandbox Code Playgroud)
这导致语法错误。令牌后面必须紧跟一个换行符。