Get URL of calling webpage in PHP

后端 未结 2 1345
旧巷少年郎
旧巷少年郎 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: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.

提交回复
热议问题