[英]how do i add a named anchor to my PHP dynamic link?
I need add a named anchor into this code: 我需要在此代码中添加一个命名锚:
<?
echo "<a href=\"reviews-mockup2.php?category=$category&keyword=" . $_REQUEST['keyword'] . "&nationalpage=";
?>
which currently looks like this in the page: 当前在页面中如下所示:
http://test.usfamilyguide.com/reviews-mockup2.php?category=&keyword=&nationalpage=1
I tried 我试过了
<?
echo "<a href=\"reviews-mockup2.php?category=$category&keyword=" . $_REQUEST['keyword'] . "&nationalpage=" . "#named-anchor";
?>
and got 并得到
http://test.usfamilyguide.com/reviews-mockup2.php?category=&keyword=&nationalpage=#named-anchor1
thanks! 谢谢!
Your anchor <a>
tags seem to have an incorrect syntax. 您的锚点<a>
标记似乎语法不正确。 Refer to W3Schools . 请参考W3Schools 。
Assuming, you are wanting it to jump to a particular section in a page; 假设您希望它跳到页面中的特定部分。 your solution should be something like this: 您的解决方案应该是这样的:
echo "<a href='reviews-mockup2.php?category={$category}&keyword={$_REQUEST['keyword']}#named-anchor'>Your Anchor Name</a>";
What I did was: removed the nationalpage
as I assumed thats what you were using to anchor to sections in the page, put all the PHP in curly braces {}
and finally fixed your tag syntax as defined in the link I gave earlier. 我所做的是:删除了nationalpage
因为我以为那是您用来锚定页面中各个部分的内容,将所有PHP放在花括号{}
,最后固定了我之前给出的链接中定义的标记语法。 This should work to how you expect. 这应该可以达到您的期望。
Any issues let me know. 任何问题都让我知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.