php中g(shù)et_headers函數(shù)的作用及用法的詳細介紹_PHP教程
推薦:php函數(shù)range() round()和list()如何使用一 range()函數(shù)快速創(chuàng)建數(shù)組的簡單方法,使用low到high范圍的整數(shù)值填充數(shù)組,函數(shù)將返回一個包含次范圍內(nèi)所有整數(shù)的數(shù)組.形式如下 array range(int low,int high[,int step]) 典型用法如下 例子:建立1-6的6個數(shù)字的數(shù)組(骰子) $die = range(0,6); 建立0-30所有雙數(shù)的數(shù)
get_headers() 是PHP系統(tǒng)級函數(shù),他返回一個包含有服務(wù)器響應(yīng)一個 HTTP 請求所發(fā)送的標頭的數(shù)組。如果失敗則返回 FALSE 并發(fā)出一條 E_WARNING 級別的錯誤信息(可用來判斷遠程文件是否存在)。
函數(shù)定義
array get_headers ( string $url [, int $format = 0 ] )
參數(shù)
url 目標 URL
format 如果將可選的 format 參數(shù)設(shè)為 1,則 get_headers() 會解析相應(yīng)的信息并設(shè)定數(shù)組的鍵名。
示例
<?php
$url='http://www.phpernote.com';
print_r(get_headers($url));
print_r(get_headers($url,1));
?>
以上例程的輸出類似于:
Array
(
[0] => HTTP/1.1 200 OK
[1] => Date: Sat, 29 May 2004 12:28:13 GMT
[2] => Server: Apache/1.3.27 (Unix) (Red-Hat/Linux)
[3] => Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
[4] => ETag: "3f80f-1b6-3e1cb03b"
[5] => Accept-Ranges: bytes
[6] => Content-Length: 438
[7] => Connection: close
[8] => Content-Type: text/html
)
Array
(
[0] => HTTP/1.1 200 OK
[Date] => Sat, 29 May 2004 12:28:14 GMT
[Server] => Apache/1.3.27 (Unix) (Red-Hat/Linux)
[Last-Modified] => Wed, 08 Jan 2003 23:11:55 GMT
[ETag] => "3f80f-1b6-3e1cb03b"
[Accept-Ranges] => bytes
[Content-Length] => 438
[Connection] => close
[Content-Type] => text/html
)
分享:php有規(guī)律大文件的讀取與寫入這幾天在做一個東西.研究PHP讀取行數(shù)較多的文件(大概上百萬行).考慮到效率問題.進行了簡單的研究.總結(jié)如下 第一條.file()函數(shù)的效率問題. file()函數(shù)的效率很底下 如果是有規(guī)律的文件.比如每行一條相應(yīng)數(shù)據(jù).那么盡量不要是用file()函數(shù) 可以使用file_get_contents()然
- 相關(guān)鏈接:
- 教程說明:
PHP教程-php中g(shù)et_headers函數(shù)的作用及用法的詳細介紹
。