We often use the file_get_contents function to open the file, in fact, this function can also open a network address, to achieve a simple web crawl, with file-get-contents open file ReadFile, such as reading the URL, will create a $ Http_response_header variable to hold the header of the HTTP response, using functions such as fopen to open the data flow information can be obtained using the Stream_get_meta_data function
$html = file_get_contents ("http://baidu.com");p Rint_r ($http _response_header);/**array ([0] = http/1.1, ok[1] = > Date:sat, 16:14:36 gmt[2] = server:apache[3] [cache-control:max-age=86400[4] = expires:s UN, 16:14:36 gmt[5] = last-modified:tue, Jan 13:48:00 gmt[6] = ETag: "51-4b4c7d90" [7] = A CCEPT-RANGES:BYTES[8] = content-length:81[9] = connection:close[10] = content-type:text/html) */$fp = fopen ("Http://baidu.com", "R");p Rint_r (Stream_get_meta_data ($fp));/**array ([wrapper_data] = = Array ([ 0] = http/1.1 [1] = Date:sat, 16:14:36 GMT [2] = Server:apache [3] = = cache-control:max-age=86400 [4] = Expires:sun, 16:14:36 GMT [5] = > Last-modified:tue, 13:48:00 GMT [6] = ETag: "51-4b4c7d90" [7] = Accept-ran Ges:bytes [8] => content-length:81 [9] = Connection:close [ten] = content-type:text/html) [Wrapp Er_type] + http [stream_type] = Tcp_socket/ssl [mode] + R [unread_bytes] = Bayi [seekable] = [URI] [http://baidu.com] [timed_out] = [blocked] = 1 [eof] = =) */
HTTP Series One