doufang3001 2012-03-30 19:44
浏览 27
已采纳

抓取Refferer的URL - PHP

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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 用51单片机控制急停。
  • ¥15 孟德尔随机化结果不一致
  • ¥15 在使用pyecharts时出现问题
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用