在heredoc中使用@ error controller

时间:2013-12-08 12:37:01

标签: php heredoc

如何在heredoc中使用@错误控制器?就像我想重新显示尚未通过验证的输入表单字段的内容一样:当我在heredoc中使用@时出现错误,如下所示:

 <<<EOS
     <input name="firstname" type="text" value="{@$_POST['firstname']}" />
 EOS;

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

1 个答案:

答案 0 :(得分:1)

你不能在你的heredoc中做到这一点,但之前很好:

$value = @<<<HDOC
    Name: {$_POST['firstname']}
HDOC;

同样适用于双引号(你展示的例子不是heredoc):

$value = @"Name: {$_POST['firstname']}";
相关问题