微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

php获取ajax的headers方法与内容实例

1.前端页面

rush:xhtml;"> Cross-<a href="/tag/bro/" target="_blank" class="keywords">bro</a>wser QRCode generator for Javascript

2.PHP页面

rush:xhtml;"> $value) //循环_SERVER数组 { if (substr($name,5) == 'HTTP_') //前5个字符是HTTP_的进入循环 { $headers[str_replace(' ','-',ucwords(strtolower(str_replace('_',' ',substr($name,5)))))] = $value; //注释 //substr($name,5),从$name第5个字符向后截取 //str_replace('_',)下划线替换成空格 //strtolower()全部转换为小写 //ucwords()首字母转换为大写 //str_replace(' ',)所有空格替换为- } } return $headers; //返回前key前5个字符是HTTP_的数组 //return $_SERVER; //返回_SERVER数组 }

3.PHP页面返回的headers

string(94) "Hm_lvt_f62fa14829605f0d29c05da9c30e045a=1503649309,1503884728; _ga=GA1.1.1091059248.1504832863" ["Accept-Language"]=> string(14) "zh-CN,zh;q=0.8" ["Accept-Encoding"]=> string(17) "gzip,deflate,br" ["Referer"]=> string(62) "http://localhost/DianNaoBengKuiFangYunDuan/qrcode/headers.html" ["Token"]=>//自定义token及值 string(12) "token7758521" ["X-Requested-With"]=> string(14) "XMLHttpRequest" ["Accept"]=> string(3) "*/*" ["User-Agent"]=> string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/61.0.3163.100 Safari/537.36" ["Origin"]=> string(16) "http://localhost" ["Connection"]=> string(5) "close" ["Host"]=> string(9) "localhost" }

4.原始的headers部分数据

string(94) "Hm_lvt_f62fa14829605f0d29c05da9c30e045a=1503649309,1503884728; _ga=GA1.1.1091059248.1504832863" ["HTTP_ACCEPT_LANGUAGE"]=> string(14) "zh-CN,zh;q=0.8" ["HTTP_ACCEPT_ENCODING"]=> string(17) "gzip,br" ["HTTP_REFERER"]=> string(62) "http://localhost/DianNaoBengKuiFangYunDuan/qrcode/headers.html" ["HTTP_TOKEN"]=>//自定义token及值 string(12) "token7758521" ["HTTP_X_REQUESTED_WITH"]=> string(14) "XMLHttpRequest" ["HTTP_ACCEPT"]=> string(3) "*/*" ["HTTP_USER_AGENT"]=> string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/61.0.3163.100 Safari/537.36" ["HTTP_ORIGIN"]=> string(16) "http://localhost" ["CONTENT_LENGTH"]=> string(1) "7" ["HTTP_CONNECTION"]=> string(5) "close" ["HTTP_HOST"]=> string(9) "localhost"

以上这篇PHP获取ajax的headers方法内容实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持编程之家。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐