解析错误:意外的EOF

时间:2018-01-23 09:13:17

标签: php eof parse-error

我有错误。它说:

  

语法错误,意外的文件结尾

<?php
{
if($_POST["submit']) {
    $recipient=\"youremail@gmail.com\";
    $subject=\"Inquiry Form\";
    $sender=$_POST [name];
    $senderEmail=$_POST [email];
    $FeedbackQuestion=$_POST [feedback];

$mailBody=\"Name: $name\nEmail:$email\n\n$feedback;

\mail($recipient, $subject, $mailbody, \"From: $name<$email>\");

$thankYou=\"Thank you! Your message has been sent.\";

} 
?>

问题是什么?

1 个答案:

答案 0 :(得分:2)

if($_POST["submit']) {替换为if($_POST["submit"]) {

"

之后看到不同的'而不是submit

然后,删除第2行的第一个{

完整正确的代码是:

<?php
if($_POST["submit"])
{
    $recipient="youremail@gmail.com";
    $subject="Inquiry Form";
    $sender=$_POST ['name'];
    $senderEmail=$_POST ['email'];
    $FeedbackQuestion=$_POST ['feedback'];

    $mailBody="Name: $name\nEmail:$email\n\n$feedback";

    mail($recipient, $subject, $mailbody, "From: $name<$email>");

    $thankYou="Thank you! Your message has been sent.";
}
?>

此外,所有\"都必须替换为“因为\"仅在"所包围的字符串中需要。

此外,数组键必须由'括起来。