2010-12-04 102 views
0

我一直在第一行收到“解析错误:语法错误,意外','期待')'”,我试过打断了字符串,但没有正确嵌入。任何人都知道如何对此进行排序?解析错误:语法错误

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>'); 
+0

您正在使用concanation运算符(`.`)。这在类成员变量中不起作用。改为使用approperiate构造函数。 – Lekensteyn 2010-12-04 22:26:07

回答

3

你不能以这种方式连接类变量定义中的数据。初始化值必须是一个常量。

试试这个:

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>'); 
} 

或者剥离级联和简单地使它成为一个多行字符串。我不确定你为什么不这样做,因为它已经由多行字符串组成。