function SendEmail() {
$to = $email;
$subject = 'Sales | Purchase Instructions';
$message = '
Thank you for your purchasing 'My Product'.
Your account information
-------------------------
Name: 'Your Name'
Email: 'Your Email'
-------------------------
You can purchase our product by clicking on the purchase button, entering product name, and quantity in the provided boxes, and then click purchase.;
$headers = 'From:My Company <me@mycompany.net>' . "\r\n";
mail($to, $subject, $message, $headers);
}
答案 0 :(得分:1)
我认为你的引号有问题。您使用'
来封装字符串,但是您也在字符串中使用这些标记,因此它不起作用,解释器不知道字符串的结束位置并引发错误。因此,您应该使用相同的引号来封装您在其中使用的字符串,或者必须转义字符串内的引号(通过在其前面放置\
)。我的建议是在字符串周围使用"
,因为你不在字符串中使用这些引号。
如果使用'
或"
封装字符串,您应该知道存在差异。当您在字符串中使用"
变量时,它们将被其值替换,但在您使用'
时则不会。
答案 1 :(得分:0)
<?php
$name = 'MonkeyZeus';
$message = 'Hi there '.$name.', <--this is a variable but this is a literal quote inside a quote --> \'';
echo $message;
?>
预期输出为:
你好MonkeyZeus,&lt; - 这是一个变量,但这是引用中的字面引用 - &gt; “