douchaqi3369 2015-08-21 11:16
浏览 33

记录脚本以查看在url中打开的参数

I want to see parameters or hash part when visitor opens my link like [https://domain.com?Random-parameter=value][1] or [https://domain.com#RandomValue][2]

In general i want to create log script on particular link, that if user opened my link and embed some hashpart in url. how to retrieve that hash part?

Which php functions could be used for this?

  • 写回答

1条回答 默认 最新

  • drsb77336 2015-08-21 11:36
    关注

    You can't by using PHP only. You can retrieve the url hash part by using javascript, then send it with ajax, for example. In javascript, the hash part of an url is stored in window.location.hash

    To treat it in php, you can use parse_url() :

    parse_url("http://test?it#nice",PHP_URL_FRAGMENT);
    

    will return "nice".

    Not a solution that I really like, but it's also possible to stock the hash as a cookie, as a workaround. You can see http://www.stoimen.com/blog/2009/04/15/read-the-anchor-part-of-the-url-with-php/ for more informations.

    See ya!

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等