请帮助我,
我正在处理PHP表单处理,我得到了这个链接
http://www.htmlgoodies.com/beyond/php/article.php/3855686
完成教程后得到以下错误。
解析错误:语法错误,第50行/home/TestSub/public_html/form/contactformprocess.php中的意外$ end
这是我的代码
<?php
$emailSubject = 'Contact Form';
$webMaster = 'Test@gmail.com';
$emailField = $_POST['email'];
$nameField = $_POST['name'];
$phoneField = $_POST['phone'];
$sexField = $_POST['sex'];
$country = $_POST['country'];
$messageField = $_POST['message'];
$newsletterField = $_POST['newsletter'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number : $phone <br>
Sex : $sex <br>
Country : $country <br>
Message : $message <br>
Newsletter : $newsletter <br>
EOD;
$headers = "From: $email\r\n";
$headers .="Content-type:text/html\r\n";
$success = mail ($webMaster,$emailSubject,$body,$headers);
$theResults = <<<EOD
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
</head>
<body>
<h1>Thank you For your intrest ! We will get back you very soon</h1>
</body>
</html>
EOD;
echo "$theResults";
?>
答案 0 :(得分:0)
据我所知,您的代码中没有语法错误。
你是否确定?EOD;
是否放在他们的行的开头?
前面不能有任何标签或空格。这会产生错误,因为heredoc声明的结束标记不在行的开头。
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number : $phone <br>
Sex : $sex <br>
Country : $country <br>
Message : $message <br>
Newsletter : $newsletter <br>
EOD; // <-- this is wrong
EOD; // <-- this is right