HEREDOC Returning unexpected end

后端 未结 1 901
太阳男子
太阳男子 2020-12-02 02:53

The following snippet is causing an

\"PHP Parse error: syntax error, unexpected $end in /Applications/MAMP/htdocs3/nettuts/PHP/PDO for Database Acces

相关标签:
1条回答
  • 2020-12-02 03:27

    You have a whole bunch of spaces (9 to be exact) after the EOT; in the loop.

    From the manual

    ... there may not be any spaces or tabs before or after the semicolon ...

    Why are you wrapping the $output variable inside a HEREDOC string? I'd just change the loop to

    printf('<tr><td align="left">%s</td><td align="left">%s</td></tr>',
           htmlspecialchars($row["name"]),
           htmlspecialchars($row["dr"]));
    

    or even better, use PHP's alternative syntax.

    0 讨论(0)
提交回复
热议问题