我正在尝试使用php邮件发送电子邮件,但是,当使用锚标记时,如果文件名中存在链接,则链接不会超过单引号(')。
以下是出现问题的代码行:
$message .= "<tr><td><strong>View LOA:</strong> </td><td><a href='http://myurl.com/loa/" . $myloa . "'>" . strip_tags($myloa) . "</a></td></tr>";
($ myloa是从我的数据库中提取的。我在我的服务器上上传了多个文件并将文件名保存在我的数据库中。)
在电子邮件中,$ myloa可以读作,例如Alex的LOA.pdf
但是,如果尝试点击它(因为它已锚定),链接只会到达Alex。所以链接看起来像这样:http://myurl.com/loa/Alex而不是http://myurl.com/loa/Alex的LOA.pdf
我该如何解决这个问题?感谢。
这是我的完整代码:
$emailloa = $_POST['emailloa'];
$to .= "" . strip_tags($emailloa) . "";
$subject = "The " . strip_tags($name) . " LOA";
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Sent by:</strong> </td><td>" . strip_tags($_SESSION['user']['first']) . " " . strip_tags($_SESSION['user']['last']) . " </td></tr>";
$message .= "<tr><td><strong>View LOA:</strong> </td><td><a href='http://myurl.com/loa/" . $myloa . "'>" . strip_tags($myloa) . "</a></td></tr>";
$message .= "</table>";
$message .= "</body></html>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
答案 0 :(得分:1)
如果换掉单引号和双引号怎么办?
$message .= '<tr><td><strong>View LOA:</strong> </td><td><a href="http://myurl.com/loa/' . $myloa . '">' . strip_tags($myloa) . '</a></td></tr>';
我想知道双引号是否正在解释翻译:http://php.net/manual/en/language.types.string.php