多行变量未创建

时间:2010-11-14 16:50:55

标签: php

以下代码有什么问题?

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;

}

1 个答案:

答案 0 :(得分:3)

您必须将heredoc EOF;的结束分隔符放在行的开头:

  

请注意,包含结束标识符的行必须不包含其他字符,但 可能 分号(;)除外。这尤其意味着标识符 可能不会缩进 ,并且在分号之前或之后可能没有任何空格或制表符。

所以:

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