将链接插入php

时间:2012-03-31 21:21:22

标签: php html

我无法将此链接放入我的PHP代码中。我总是搞砸引号,混合html和php。

$message = "Please verify your account.  Please click on the following link to verify your      account: <a href='confirm.php?code=$code'> here</a>. If you should have any problems activating your account, please e-mail us at contact@mywebsite.com";

2 个答案:

答案 0 :(得分:3)

用单引号将其包装

$message = 'Please verify your account. Please click on the following link to verify your account: <a href="confirm.php?code=' . $code . '"> here</a>. If you should have any problems activating your account, please e-mail us at contact@mywebsite.com';

如果用单引号括起来,可以使用双引号,反之亦然。如果你需要单引号并且用单引号括起来,使用\对其进行转义,你不能在单引号中使用变量而不能将它们连接起来

答案 1 :(得分:0)

$message = 'We endeavor you to verify your account.  Please click on the following link to verify your account: <a href="confirm.php?code=' . $code . '">Verification link</a>. If you should have any problems activating your account, please e-mail us at <a href="mailto:contact@mywebsite.com">our customer support e-mail address.</a> Thank you.';
相关问题