2012-03-31 37 views
-1

我有麻烦把这个链接到我的PHP代码。我总是搞砸了引号,并混合HTML和PHP。插入链接到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 [email protected]"; 
+3

而你的问题是什么? – 2012-03-31 21:24:20

+0

@真正的问题是在定义变量时滥用双引号 – Tom 2012-03-31 21:37:02

+0

@Tom我没有看到变量的定义问题。你在哪里看到一个双引号滥用? – 2012-03-31 21:40:13

回答

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 [email protected]';

如果在单引号,您可以使用双引号,反之亦然包裹。如果你需要使用单引号,它是包裹着单引号,使用\你不能使用单引号的变量与出逃避它的concat-ING他们虽然

+0

当我这样做,我得到一个错误:“confirm.php码= $代码” – droidus 2012-03-31 21:25:32

+0

上面的代码将无法正常工作,因为你已经使用单引号表示anchor属性。更改为双引号 – Tom 2012-03-31 21:25:38

+0

刷新,我只是更新了它 – 2012-03-31 21:26:16

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:[email protected]">our customer support e-mail address.</a> Thank you.';