Get URL of calling webpage in PHP

后端 未结 2 1325
旧巷少年郎
旧巷少年郎 2021-01-05 17:45

I am working on a website statistics engine for a class. The idea being that you can simply embed a little code in your web page which will call the stats website on every p

相关标签:
2条回答
  • 2021-01-05 18:21

    $_SERVER['HTTP_REFERER'] will get you the referring page.

    0 讨论(0)
  • 2021-01-05 18:29

    In addition to $_SERVER['HTTP_REFERER'] since there may be large chunks of the URI you wish to ignore, you can just pass the page name as a request param to the called script.

    I.E. on the page with stats tracking you request

    URL/stats_tracker.php?page=checkout
    

    on the stats tracker page you just look for

    $_REQUEST['page'];
    

    This can be cleaner than looking at the whole URL.

    0 讨论(0)
提交回复
热议问题