front page of 

< DOCTYPE HTML PUBLIC! "-//W3C//DTD XHTML 1" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "Transitional//EN" > < HTML "xmlns= http:// www.w3.org/1999/xhtml" xml:lang= "Ko" lang= "Ko" > < head> < title> Cross-Browser QRCode generator for Javascript< /title> < meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8 /> < meta; name=" viewport "content=" width=device-width, initial-scale=1, user-scalable=no, /> < script "type=" text/javascript "src=" jquery.min.js "> < /script> < script type=" text/javascript "src=" qrcode.js & gt; < /script> < /head> < body> < button> /button> < on < Script type= "text/javascript" > $(".Suning") (.Click (function) {$.ajax {url: ('headers.php', data::'123'}, {'key' / / if you need to string JSON, please use the JSON.stringify (setting.data) type:'POST', //dataType:'json', //contentType:'application/json', //processData: true, true beforeSend: / / does not serialize data (function {/ / layer.load) (2);}, {"token": headers:'token7758521'// and success: token custom value function (responseData)}, {console.log}; (responseData), error: function (error) {console.log (error);}});}); < /script> < /body>

2.php

 < PHP page;? $arr = get_getallheaders (HTTP); / / get the head $arr[array //echo "Token"]; / / Token var output _dump ($arr); / / function (get_getallheaders) output of the whole array / / definition method ($_SERVER as $name {foreach => $value) {if (_SERVER / circular array substr ($name, 0, 5) = ='HTTP_') / / the first 5 characters are HTTP_ into circulation {$headers[(' ', str_replace' - ', ucwords (strtolower (str_replace ('_', '', substr ($name, 5)))))] = $value; / / note //substr ($name, 5), from $name to fifth characters ('_', back to intercept //str_replace' ') underline replaced space / / strtolower () //ucwords () are converted to lowercase first the letters are converted to uppercase //str_replace (' '' - ',) all replace spaces}} - return $headers; / / return to key before the 5 character is an array of HTTP_ //return $_SERVER; / / 

< span} return an array of _SERVER style= "color: #ff0000 >3.php" page Return to the headers

 array (11) {["Cookie"]=> string (94) "Hm_lvt_f62fa14829605f0d29c05da9c30e045a=15036493091503884728; _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 and custom value string (12)" token7758521 "" X-Requested-With "]=> string (14)" XMLHttpRequest "" Accept "]=> string (3)" * / * "[" User-Agent]=> "string" (Mozilla/5.0 (110) Windows NT 10; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 "" Origin "]=> string (16)" http://localhost "/" Conne Ction]=> string (5) "close" "Host"]=> string (9) "localhost"}

4. headers

 the original data ["HTTP_COOKIE"]=> string Hm_lvt_f62fa14829605f0d29c05da9c30e045a=15036493091503884728; (94) "_ga=GA1.1.1091059248.1504832863" ["HTTP_ACCEPT_LANGUAGE"]=> string (14) "zh-CN zh," ["HTTP_ACCEPT_ENCODING"; q=0.8]=> string (17) gzip, deflate, Br "HTTP_REFERER"]=> "; string (62)" http://localhost/DianNaoBengKuiFangYunDuan/qrcode/headers.html "/" HTTP_TOKEN "]=> / / token and custom value 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; 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)" and "

localhost headers method above this PHP access to the Ajax instance is the small share to all people, I hope to give you a reference, I hope you will support a script.


This concludes the body part