PHP:回显一个href
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20790290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP : echo a href
提问by JinSnow
I have this php line which works fine:
我有这个 php 行,它工作正常:
echo "<p><a href=\"https://www.facebook.com/". $post['id'] . "\"target=\"_blank\">" . $post['message']. "</a></p>";
But I want to change it so it will link to my page (not to a single post). So it should look like that.
但我想更改它,以便它链接到我的页面(而不是单个帖子)。所以它应该是这样的。
echo "<p><a href=\"https://www.facebook.com/rscmovement" "\"target=\"_blank\">" . $post['message']. "</a></p>";
I have tried a lot many proposition gathered on different website, but each time I am getting an error.
我尝试了很多收集在不同网站上的提议,但每次都出现错误。
Any idea ?
任何的想法 ?
Thanks a lot!
非常感谢!
回答by davewoodhall
Using single and double quotes, you avoid escaping issues. Try this:
使用单引号和双引号可以避免转义问题。尝试这个:
echo '<p><a href="https://www.facebook.com/rscmovement" target="_blank">'. $post['message']. '</a></p>';
回答by Khaled Saif
I guess You have missed the back slash () before " after www.facebook.com/rscmovement. "
我猜您在“www.facebook.com/rscmovement”之后错过了反斜杠 ()。
https://www.facebook.com/rscmovement\" "\"target=\"_blank\">" will
https://www.facebook.com/rscmovement\" "\"target=\"_blank\">" 将
回答by semirturgay
i see that you didn't escaped from double quote that closes href attribute:
我看到你没有从关闭 href 属性的双引号中逃脱:
echo "<p><a href=\"https://www.facebook.com/rscmovement\" target=\"_blank\">"

