开发者

Parse error: syntax error [closed]

开发者 https://www.devze.com 2023-01-29 02:00 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

I keep getting "Parse error: syntax error, unexpected '.', expecting ')'" on the first line, I've tried breaking the string up, but then it doesn't embed properly. 开发者_高级运维Anybody know how to sort this?

protected $_embedHTML = array('youtube' => '<object width="425" height="350"
                                            type="application/x-shockwave-flash" '.
                                            'data="http://www.youtube.com/'.$value.'">'.
                                            '<param name="movie" value="http://www.youtube.com/'.$value.'">
                                            </param>'.
                                            '<!--[if IE]>'.
                                            '<embed src="http://www.youtube.com/'.$value.'"'.
                                            'type="application/x-shockwave-flash"'.
                                            'wmode="transparent" width="425" height="350" />'.
                                            '<![endif]-->'.
                                            '</object>');


You can't concatenate data in a class variable definition that way. The initialization value has to be a constant.

Try this:

protected $_embedHTML;

function __construct() {
  $this->_embedHTML = array('youtube' => '<object width="425" height="350"
      type="application/x-shockwave-flash" '.
      data="http://www.youtube.com/'.$value.'">'.
      '<param name="movie" value="http://www.youtube.com/'.$value.'">
      </param>'.
      '<!--[if IE]>'.
      '<embed src="http://www.youtube.com/'.$value.'"'.
      'type="application/x-shockwave-flash"'.
      'wmode="transparent" width="425" height="350" />'.
      '<![endif]-->'.
      '</object>');
}

Or, strip the concatenation and simply make it a multiline string. I'm not sure why you're not doing this, as it is already composed of multiline strings.

0

精彩评论

暂无评论...
验证码 换一张
取 消