doula4096 2014-03-15 00:21
浏览 44

如何使用$ _SERVER获取#post [duplicate]的所有链接或数量

My links are like this

http://sitename.com/test/t9.html#post23

I want to get the full link from the browser, or get only number of the post from it

I've tried:

$_SERVER['SERVER_NAME'];
$_SERVER['REQUEST_URI'];

But this show me only before the hash

http://sitename.com/test/t9.html#post23

i want get all link or the number after hash 23

</div>
  • 写回答

2条回答 默认 最新

  • dongwen7730 2014-03-15 00:26
    关注

    The anchor (#) section of the URL is not passed through to PHP, so you'll be unable to get access to it as you're expecting.

    You'll need to use javascript to grab it like this:

    <script>alert(window.location.hash);</script>
    

    And perhaps then use ajax to send that through to your PHP

    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行