我有这个链接:
www.something.com/index.php?page=teams
然后我有这个链接:
<a href="?profile=5">Profile</a>
我要实现的是这个链接:
www.something.com/index.php?page=teams&profile=5
但我得到的是这个:
www.something.com?profile=5
棘手的部分是我不能像这样写整个“路径”:
<a href="http://www.something.com/index.php?page=teams&profile=5">Profile</a>
因为它并不总是在“团队”页面上。
这可能是一个非常愚蠢的问题,但我真的想不通。
最佳答案
您必须在 href 中包含 page=teams 参数。
代替
<a href="?profile=5">Profile</a>
有点像
<a href="./page=teams&profile=5">Profile</a>
如果该链接是静态的,您必须更新 html 文件。 但是如果 page=anyvalue 那么你必须在你的 php 代码中动态生成 href 链接 例如:
<a href="<?php echo "./page=$page&profile=5"; ?>"></a>
其中 $page 是当前页面,例如 $page="teams"
关于php - 使用获取变量扩展链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21895814/