PHP Get Ajax Headers method and content examples to explain

Source: Internet
Author: User
The following small series for you to share a PHP to get Ajax headers method and content examples, has a good reference value, I hope to be helpful to everyone. Let's take a look at it with a little knitting.

1. Front Page

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

2.php page

<?php$arr = Get_getallheaders ();//Get HTTP header array//echo $arr ["Token"];//output tokenvar_dump ($arr);//output entire array function get_ Getallheaders ()//define method {  foreach ($_server as $name = $value)//loop _server Array {  if (substr ($name, 0, 5) = = ' Http_ ')///The first 5 characters are http_ into the loop {  $headers [Str_replace (', '-', Ucwords (Strtolower (' _ ', ', ' Str_replace ($name, 5))) )] = $value;  Note//substr ($name, 5), from $name 5th character to intercept//str_replace (' _ ', ', '), replace the underscore with a space//strtolower () convert all to lowercase//ucwords () convert the first letter to uppercase// Str_replace (', '-',) all spaces are replaced with-}  }  return $headers;//Return the first 5 characters before key is http_ array//return $_server;//return _server array}

3.php page returned by headers

Array (one) {["Cookie"]=> string (94) "hm_lvt_f62fa14829605f0d29c05da9c30e045a=1503649309,1503884728; _ga=ga1.1.1091059248.1504832863 "[" Accept-language "]=> string" zh-cn,zh;q=0.8 "[" Accept-encoding "]=> String (+) "gzip, deflate, BR" ["Referer"]=> string "http://localhost/DianNaoBengKuiFangYunDuan/qrcode/ Headers.html "[" token "]=>//custom Token and value string (" token7758521 "[" X-requested-with "]=> string (14)" XMLHttpRequest "[" Accept "]=> string (3)" */* "[" User-agent "]=> string ()" mozilla/5.0 (Windows NT 10.0; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/61.0.3163.100 safari/537.36 "[Origin"]=> string (+/) "HTTP/ localhost "[" Connection "]=> string (5)" Close "[" Host "]=> string (9)" localhost "}

4. Original headers part data

["Http_cookie"]=> string (94) "hm_lvt_f62fa14829605f0d29c05da9c30e045a=1503649309,1503884728; _ga=ga1.1.1091059248.1504832863 "[" Http_accept_language "]=> string" zh-cn,zh;q=0.8 "[" Http_accept_encoding " ]=> string (+) "gzip, deflate, BR" ["Http_referer"]=> string () "http://localhost/DianNaoBengKuiFangYunDuan/ Qrcode/headers.html "[" Http_token "]=>//custom TOKEN and value string ()" token7758521 "[" Http_x_requested_with "]=> String "XMLHttpRequest" ["Http_accept"]=> string (3) "*/*" ["Http_user_agent"]=> string () "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 (+)" HTTP ://localhost "[" Content_length "]=> string (1)" 7 "[" Http_connection "]=> string (5)" Close "[" Http_host "]=> String (9) "localhost"

Above this PHP get Ajax headers method and content instance is small to share all the content, hope to give you a reference, also hope that we support PHP Chinese web.

Articles you may be interested in:

The most basic operating tutorial on using queue in Laravel

Detailed explanation of YAF framework PHPUnit Integration test method

Quick troubleshooting PHP calls to Word component DCOM permissions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.