Php 以下两种邮件功能的区别是什么?

Php 以下两种邮件功能的区别是什么?,php,Php,我似乎不明白为什么第一个代码的语法会出现t_字符串错误,因为它看起来与第二个代码相同: $htmlContent = "<h1>Congratulation Level 1 Promo Winner!</h1> <p>Dear $_SESSION['u_first'] $_SESSION['u_last'], &

我似乎不明白为什么第一个代码的语法会出现t_字符串错误,因为它看起来与第二个代码相同:

 $htmlContent = "<h1>Congratulation Level 1 Promo Winner!</h1>
                                                                          <p>Dear $_SESSION['u_first'] $_SESSION['u_last'], <br /> Thank you for participating in our Level 1 Promo Competition recently. You have been selected as a winner in the following competition id: $row['entry_id']. You must activate your Level 1 Promo Code by clicking on the following link here <a href=https://www.pianocourse101.com/includes/activatelevel1promo.php?email=".htmlspecialchars($to)."&activatetoken=".htmlspecialchars($level1promocode).">Click here to activate your Level 1 Promo Code.</a>Alternatively, you can use the following token to manually activate your Level 1 Promo Code by clicking on the Activate Membership Section Token:.$level1promocode
                                                                      </p>"; 
$htmlContent=“祝贺1级促销赢家!
尊敬的$_SESSION['u_first']$_SESSION['u_last'],
感谢您最近参加我们的1级促销活动竞赛。您已被选为以下竞赛id的获胜者:$row['entry_id']。您必须通过单击此处的以下链接来激活您的1级促销代码。或者,您可以使用以下令牌通过单击激活会员资格部分令牌来手动激活您的1级促销代码:。$level1promocode

”;
与此代码相比:

 $htmlContent = "<h1>Activate your Primer Level Membership Plan!</h1>
                                                                          <p>Dear $first $last, <br />Thank you for registering your Primer Level Membership Plan with PianoCourse101! You are receiving this e-mail because you or someone else claiming to be you has selected a Primer Level Membership Plan \n\nIf you believe that this is a mistake, please send us a ticket with the subject \"How to cancel my Primer Level Membership Plan?\" and allow at least 48 hours before receiving a reply.\n\nHowever, if this is correct, then you must activate your Primer Level Membership Plan by clicking on the link below: \n\n <a href=https://www.pianocourse101.com/includes/activate.php?email=".htmlspecialchars($to)."&activatetoken=".htmlspecialchars($token4).">Click here to activate your Primer Level Membership Plan.</a>\n\nAlternatively, you can use the following token to manually activate your Level 3 Yearly Membership Plan by clicking on the 'Activate Membership\s Section:' \n\nToken:.$token4;
                                                                      </p>";
$htmlContent=“激活初级会员计划!
亲爱的$first$last,
感谢您向PianoCourse101注册初级会员计划!您收到此电子邮件是因为您或自称您的其他人选择了初级会员计划\n\n如果您认为这是一个错误,请向我们发送一张主题为\”的票证如何取消初级会员计划\并在收到答复之前至少等待48小时。\n\n但是,如果这是正确的,则必须通过单击下面的链接激活初级成员计划:\n\n\n\n或者,通过单击“激活会员资格”部分,您可以使用以下令牌手动激活您的3级年度会员计划:'\n\n令牌:.$token4;

”;
第一个代码:

此处会话是通过以下代码为特定用户创建的:

$_SESSION['u_first'] $_SESSION['u_last']
第二个代码:
在这里,我们已经创建了会话并为变量赋值,以便用于在第一个代码上显示用户信息。使用$\u session[],这是一个数组。如果要将字符串与数组值连接起来,则需要放置适当的引号(“)

在第二个代码中,您使用的是变量。在这种情况下,您可以正常地将字符串与变量值连接起来

您可以从这里检查您的第一个代码。我做了一些“更新”标记

$htmlContent=“祝贺1级促销赢家 亲爱的“$\u SESSION['u_first'].$\u SESSION['u_last'.]”,
感谢您最近参加我们的一级促销活动竞赛。您已在以下竞赛id中被选为赢家:“.$row['entry_id']”。您必须通过单击此处的以下链接激活您的1级促销代码。或者,您可以使用以下令牌通过单击激活会员资格部分令牌手动激活您的1级促销代码:$level1promocode

”;
请阅读。格式化也会对您的问题大有帮助。阅读两行超长的代码非常困难,更不用说调试了。我知道是怎么回事……这是一个语法错误谢谢……我已经知道了,但现在我遇到了这个错误,但我的url是正确的
   $htmlContent = "<h1>Congratulation Level 1 Promo Winner!</h1><p>Dear ".$_SESSION['u_first'].$_SESSION['u_last'].", <br /> Thank you for participating in our Level 1 Promo Competition recently. You have been selected as a winner in the following competition id:". $row['entry_id']." You must activate your Level 1 Promo Code by clicking on the following link here <a href=https://www.pianocourse101.com/includes/activatelevel1promo.php?email=".htmlspecialchars($to)."&activatetoken=".htmlspecialchars($level1promocode).">Click here to activate your Level 1 Promo Code.</a>Alternatively, you can use the following token to manually activate your Level 1 Promo Code by clicking on the Activate Membership Section Token:$level1promocode</p>";