欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

利用PHP怎么對(duì)http請(qǐng)求頭的信息進(jìn)行獲取-創(chuàng)新互聯(lián)

本篇文章給大家分享的是有關(guān)利用PHP怎么對(duì)http請(qǐng)求頭的信息進(jìn)行獲取,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說(shuō),跟著小編一起來(lái)看看吧。

成都創(chuàng)新互聯(lián)公司主營(yíng)英山網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都app軟件開(kāi)發(fā)公司,英山h5小程序制作搭建,英山網(wǎng)站營(yíng)銷(xiāo)推廣歡迎英山等地區(qū)企業(yè)咨詢(xún)

PHP手冊(cè)提供了現(xiàn)成的函數(shù):
getallheaders
(PHP 4, PHP 5)
getallheaders — Fetch all HTTP request headers
說(shuō)明
array getallheaders ( void )
Fetches all HTTP headers from the current request.
This function is an alias for apache_request_headers(). Please read theapache_request_headers() documentation for more information on how this function works.
返回值
An associative array of all the HTTP headers in the current request, orFALSE on failure.
Example #1 getallheaders() example


復(fù)制代碼 代碼如下:


<?php
foreach (getallheaders() as $name => $value) {
echo "$name: $value\n";
}
?>



不過(guò)這個(gè)函數(shù)只能在apache環(huán)境下使用,iis或者nginx并不支持,可以通過(guò)自定義函數(shù)實(shí)現(xiàn)


復(fù)制代碼 代碼如下:


<?php
<SPAN class=html>if (!function_exists('getallheaders'))
{
&nbsp;&nbsp;&nbsp; function getallheaders()
&nbsp;&nbsp;&nbsp; {
&nbsp;&nbsp; &nbsp; &nbsp; foreach ($_SERVER as $name => $value)
&nbsp;&nbsp; &nbsp; &nbsp; {
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (substr($name, 0, 5) == 'HTTP_')
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
&nbsp;&nbsp; &nbsp; &nbsp; }
&nbsp;&nbsp; &nbsp; &nbsp; return $headers;
&nbsp;&nbsp;&nbsp; }
}</SPAN>
?>



好了,看看都打印出了啥吧


復(fù)制代碼 代碼如下:


<?php
print_r(getallheaders());



獲得結(jié)果:


復(fù)制代碼 代碼如下:


Array
(
[Accept] => */*
[Accept-Language] => zh-cn
[Accept-Encoding] => gzip, deflate
[User-Agent] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)
[Host] => localhost
[Connection] => Keep-Alive
)


以上就是利用PHP怎么對(duì)http請(qǐng)求頭的信息進(jìn)行獲取,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

分享標(biāo)題:利用PHP怎么對(duì)http請(qǐng)求頭的信息進(jìn)行獲取-創(chuàng)新互聯(lián)
文章起源:http://chinadenli.net/article26/cohgjg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開(kāi)發(fā)網(wǎng)站維護(hù)標(biāo)簽優(yōu)化網(wǎng)站內(nèi)鏈網(wǎng)頁(yè)設(shè)計(jì)公司虛擬主機(jī)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都app開(kāi)發(fā)公司