2010-11-14 85 views
1

有人可以告诉下面的代码有什么问题吗?多行变量没有创建

class EMAIL_BODY{ 
    public $REGISTRATION = <<<EOF 
     <html> 
       <head> 
       </head> 
       <body style='font-family: helvetica;'> 
         Welcome <b>#{FIRST}</b>, <br/> You have successfully created your account. 
         However, there is one more step that you need to take to verify your account. 
         Please click the below given link to activate your account. 
         Unless you do that your account won\'t get activated. <br/> 

         <a> #{LINK} </a> 

       </body> 
     </html> 

    EOF; 

} 

感谢提前:)

回答

3

你必须把你的heredocEOF;的结束分隔符就在该行的开头:

这是非常重要的一点必须指出,行结束标识符必须不包含其他字符,除了可能分号(;)。这意味着特别是标识符可能不缩进,并且在分号之前或之后可能没有任何空格或制表符。

所以:

class EMAIL_BODY{ 
    public $REGISTRATION = <<<EOF 
     … 
EOF; 
} 
+0

你的意思是在结尾行没有空格?我尝试过,但仍然无法正常工作。 – TCM 2010-11-14 16:53:34

+0

@Ankit Rathod:是的,确切的。 – Gumbo 2010-11-14 16:54:55

+0

我试过那个Gumbo,但是Netbeans仍在抱怨:( – TCM 2010-11-14 16:55:33