将PHP变量添加到HTML href

将PHP变量添加到HTML href,php,html,Php,Html,我需要在我的url中添加两个变量以使其更安全。但是我不能在我的href中添加php 代码如下: <php $token =1; $email =2; $body=' <body> <p>Use the link below to reset your password.</p><br> <a href="http://localhost/wwi/view/pw_reset.php?token=<?php echo $token?&

我需要在我的url中添加两个变量以使其更安全。但是我不能在我的href中添加php

代码如下:

<php
$token =1;
$email =2;
$body='
<body>
<p>Use the link below to reset your password.</p><br>
<a href="http://localhost/wwi/view/pw_reset.php?token=<?php echo $token?>&email=<?php echo $email?>">Click here</a>
</body>';
试试这个

$token =1;
$email =2;
$body='
<body>
    <p>Use the link below to reset your password.</p><br>
    <a href="http://localhost/wwi/view/pw_reset.php?token='. $token'. '&email='. $email">Click here</a>
</body>';
$token=1;
$email=2;
$body=
使用下面的链接重置密码。


';
您忘记了
开头的
应该是
您的代码应该是


您好,您可以使用下面的代码,它将适用于您

<?php

 $token =1;
 $email =2;
 $body='
 <body>
 <p>Use the link below to reset your password.</p><br>
 <a href="http://localhost/wwi/view/pw_reset.php?token='.$token.'&email='.$email.'" > Click here </a>
 </body>';

看起来您遗漏了php echo语句末尾的半科伦。我已经在答案中输入了正确的代码。这是否回答了你的问题@达曼,这是自我推销吗D OP没有问如何正确制作,他面临一个问题。问题在标签上。无法解释的重复。哦,对不起,我没看到。我为什么要试试这个?你看到了。在答案中。请提供一些解释。他们正在构建URL而不是字符串。“这是不一样的。”达曼,OP把它当作一根绳子。所以,如果你想重写他的项目-联系他。这是不推荐的网址。您应该使用http_build_query.yeahright@Dharman,但这里我只修复了现有代码中的错误。
$token =1;
$email =2;
$body='
<body>
<p>Use the link below to reset your password.</p><br>
<a href="http://localhost/wwi/view/pw_reset.php?token='.$token.'&email='.$email.'">Click here</a>
</body>';
<?php

 $token =1;
 $email =2;
 $body='
 <body>
 <p>Use the link below to reset your password.</p><br>
 <a href="http://localhost/wwi/view/pw_reset.php?token='.$token.'&email='.$email.'" > Click here </a>
 </body>';