在echo语句中添加php变量作为href链接地址? [英] Add php variable inside echo statement as href link address?
本文介绍了在echo语句中添加php变量作为href链接地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用php变量在echo语句中为链接添加href值.
I'm trying to use a php variable to add a href value for a link in an echo statement.
这是我要使用的代码的简化版本.我知道我不能只是将变量添加到echo语句中,但似乎无法在任何可行的地方找到示例.
Here's a simplified version of the code I want to use. I know that I can't just add the variable into the echo statement, but I can't seem to find an example anywhere that works.
$link_address = '#';
echo '<a href="$link_address">Link</a>';
任何指针都表示赞赏.
推荐答案
尝试一下
PHP中的HTML:
echo "<a href='".$link_address."'>Link</a>";
或者甚至您可以尝试
echo "<a href='$link_address'>Link</a>";
或者您可以使用HTML之类的PHP
Or you can use PHP in HTML like
HTML中的PHP:
<a href="<?php echo $link_address;?>"> Link </a>
这篇关于在echo语句中添加php变量作为href链接地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文