duanjianfu1398 2013-12-03 19:53
浏览 60
已采纳

如何从apache_request_headers()中提取主机(域);

How to extract the domain (host value) from the apache_request_headers(); output?

the original code:

$headers = apache_request_headers();
foreach ($headers as $header => $value) {
    echo "$header: $value <br />
";
}

the result:

Host: yatko.net 
Connection: keep-alive 
Cache-Control: max-age=0 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 
Accept-Encoding: gzip,deflate,sdch 
Accept-Language: en-US,en;q=0.8 

the desired output would be

yatko.net

I am having a strange issue with a mail form (http://goo.gl/Wr4sfC) and seems that apache_request_headers(); would work; however, I need to extract it from the generated array. Thank you!

  • 写回答

1条回答

  • dqxm14187 2013-12-03 19:54
    关注

    You've answered your own question.

    echo $headers['Host'];
    // yatko.net
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的