php 中 html 的 Heredoc
Heredoc for html in php
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;
我也可以为 flashvars
值使用 heredoc(即另一个 heredoc 中的 heredoc)。
您在 <<<HTML
之后有一个 space:
$html = <<<HTML
here---^
这是导致语法错误的原因。令牌必须紧跟换行符。
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;
我也可以为 flashvars
值使用 heredoc(即另一个 heredoc 中的 heredoc)。
您在 <<<HTML
之后有一个 space:
$html = <<<HTML
here---^
这是导致语法错误的原因。令牌必须紧跟换行符。