I am trying to grab statistics on my site and I need a way in PHP to assign just the referrer URL to a variable. All I want is just the "www" or subdomain, the domain, and the tld... I.E. www.facebook.com instead of http://www.facebook.com/BLAH-BLAH/?blah=blah
2条回答 默认 最新
- dongzanxun2790 2012-03-30 19:50关注
Try something like the following:
$referer = $_SERVER['HTTP_REFERER']; $parts = parse_url($referer); echo $parts['host']; //should echo example.com, or whatever
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报