以下两个邮件功能有什么区别?

时间:2019-01-30 04:27:52

标签: php

我似乎无法弄清楚为什么对于第一个代码,我的语法出现t_string错误,因为它看起来与第二个代码相同:

 $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 = "<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>";

2 个答案:

答案 0 :(得分:0)

第一个代码:

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

$_SESSION['u_first'] $_SESSION['u_last']

第二个代码: 在这里,我们已经创建了会话并分配了变量,以便用于显示用户信息

答案 1 :(得分:0)

您的第一个代码。使用$ _SESSION [],即一个数组。如果要将字符串与数组值连接在一起,则需要放置正确的引号(“)。

在第二个代码上,您正在使用变量。因为您可以像平常那样将字符串与可变值连接起来

您可以从此处检查您的第一个代码。我已经更新了一些“标记”。

   $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>";