简体   繁体   English

与 php 锚点和哈希链接

[英]Link with php anchor and hash

I want to echo a html link and add a php anchor and a hash anchor.我想回显一个 html 链接并添加一个 php 锚点和一个哈希锚点。

<?php 
echo '<a href="test.php?page='.$i.'#hash">'.$i.'</a>';
?>

PHP echoes the link correctly, but after clicking on it, the browser cares only about the hash anchor. PHP 正确回显链接,但点击它后,浏览器只关心哈希锚点。 If I manually type the link in url, it runs correctly.如果我在 url 中手动输入链接,它会正确运行。 Is there a way how to trick the browser to accept both, php anchor and hash anchor?有没有办法让浏览器同时接受 php 锚点和哈希锚点?

Thanks a lot :)非常感谢 :)

Try this:尝试这个:

if (is_numeric($i)){echo '<a href="test.php?page='.$i.'#hash">'.$i.'</a>';}
else {echo 'value of i is not numeric<br>';}
if (!isset($i)){echo 'i has not been assigned ANY value at all<br>';}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM