21,887
社区成员
发帖
与我相关
我的任务
分享
<?php
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
echo "$header: $value <br />\n";
}
echo $headers['Request-Type']; // 这个应该是你要的。
?>
header('Request-Type: get_template_category');
$str="POST /store/GetAllClass.php HTTP/1.1
Accept: */*
Referer: http://192.168.1.198/
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Content-Type: application/x-www-form-urlencoded
Host: 192.168.1.198
Request-Type: get_template_category
Content-Length: 0
Connection: close
Cache-Control: no-cache";
$header=explode("\r\n",$str);
foreach($header as $key=>$value){
if(strpos($value,":")){
$hi = explode(":",$value);
$header[$hi[0]]=trim($hi[1]);
}else{
$hi = explode(" ",$value);
$header["Method"]=$hi[0];
$header["RequestURI"]=$hi[1];
}
unset($header[$key]);
}
print_r($header);