user2650277
user2650277

Reputation: 6739

Heredoc for html in php

The heredoc isn't working for the following code

    $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;

Also can i use a heredoc for the flashvars value as well (i.e a heredoc inside another heredoc).

Upvotes: 1

Views: 6252

Answers (1)

Barmar
Barmar

Reputation: 780818

You have a space after <<<HTML:

$html = <<<HTML 
        here---^

This is causing the syntax error. The token has to be followed immediately by a newline.

Upvotes: 8

Related Questions