We often use the file_get_contents function to open files. In fact, this function has another function.
We often use the file_get_contents function to open files. In fact, this function can also open a network address for simple web page capturing. when reading URLs using file-get-contents open file readfile, A $ http_response_header variable is created to save the http response header. you can use the fopen function to open the data stream information and obtain it using the stream_get_meta_data function.
$html = file_get_contents("http://baidu.com");print_r($http_response_header);/**Array([0] => HTTP/1.1 200 OK[1] => Date: Sat, 15 Nov 2014 16:14:36 GMT[2] => Server: Apache[3] => Cache-Control: max-age=86400[4] => Expires: Sun, 16 Nov 2014 16:14:36 GMT[5] => Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT[6] => ETag: "51-4b4c7d90"[7] => Accept-Ranges: bytes[8] => Content-Length: 81[9] => Connection: Close[10] => Content-Type: text/html)*/$fp = fopen("http://baidu.com", "r");print_r(stream_get_meta_data($fp));/**Array( [wrapper_data] => Array ( [0] => HTTP/1.1 200 OK [1] => Date: Sat, 15 Nov 2014 16:14:36 GMT [2] => Server: Apache [3] => Cache-Control: max-age=86400 [4] => Expires: Sun, 16 Nov 2014 16:14:36 GMT [5] => Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT [6] => ETag: "51-4b4c7d90" [7] => Accept-Ranges: bytes [8] => Content-Length: 81 [9] => Connection: Close [10] => Content-Type: text/html ) [wrapper_type] => http [stream_type] => tcp_socket/ssl [mode] => r [unread_bytes] => 81 [seekable] => [uri] => http://baidu.com [timed_out] => [blocked] => 1 [eof] => )*/