当前位置: 代码迷 >> PHP >> heredoc 不能用于循环中?该如何处理
  详细解决方案

heredoc 不能用于循环中?该如何处理

热度:266   发布时间:2012-05-10 16:02:39.0
heredoc 不能用于循环中?
PHP code

$array = array(1,2,3,4);
foreach($array AS $i){
    echo <<<HTML
    $i
    HTML;
}


出错 Parse error: syntax error, unexpected $end
while for 都会有问题

------解决方案--------------------
HTML;
结束的标记要顶格!