Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stream_get_meta_data(3) [php man page]

STREAM_GET_META_DATA(3) 						 1						   STREAM_GET_META_DATA(3)

stream_get_meta_data - Retrieves header/meta data from streams/file pointers

SYNOPSIS
array stream_get_meta_data (resource $stream) DESCRIPTION
Returns information about an existing $stream. PARAMETERS
o $stream - The stream can be any stream created by fopen(3), fsockopen(3) and pfsockopen(3). RETURN VALUES
The result array contains the following items: o timed_out (bool) - TRUE if the stream timed out while waiting for data on the last call to fread(3) or fgets(3). o blocked (bool) - TRUE if the stream is in blocking IO mode. See stream_set_blocking(3). o eof (bool) - TRUE if the stream has reached end-of-file. Note that for socket streams this member can be TRUE even when unread_bytes is non-zero. To determine if there is more data to be read, use feof(3) instead of reading this item. o unread_bytes (int) - the number of bytes currently contained in the PHP's own internal buffer. Note You shouldn't use this value in a script. o stream_type (string) - a label describing the underlying implementation of the stream. o wrapper_type (string) - a label describing the protocol wrapper implementation layered over the stream. See "Supported Protocols and Wrappers" for more information about wrappers. o wrapper_data (mixed) - wrapper specific data attached to this stream. See "Supported Protocols and Wrappers" for more information about wrappers and their wrapper data. o mode (string) - the type of access required for this stream (see Table 1 of the fopen() reference) o seekable (bool) - whether the current stream can be seeked. o uri (string) - the URI/filename associated with this stream. EXAMPLES
Example #1 stream_get_meta_data(3) example <?php $url = 'http://www.example.com/'; if (!$fp = fopen($url, 'r')) { trigger_error("Unable to open URL ($url)", E_USER_ERROR); } $meta = stream_get_meta_data($fp); print_r($meta); fclose($fp); ?> The above example will output something similar to: Array ( [wrapper_data] => Array ( [0] => HTTP/1.1 200 OK [1] => Server: Apache/2.2.3 (Red Hat) [2] => Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT [3] => ETag: "b300b4-1b6-4059a80bfd280" [4] => Accept-Ranges: bytes [5] => Content-Type: text/html; charset=UTF-8 [6] => Set-Cookie: FOO=BAR; expires=Fri, 21-Dec-2012 12:00:00 GMT; path=/; domain=.example.com [6] => Connection: close [7] => Date: Fri, 16 Oct 2009 12:00:00 GMT [8] => Age: 1164 [9] => Content-Length: 438 ) [wrapper_type] => http [stream_type] => tcp_socket/ssl [mode] => r [unread_bytes] => 438 [seekable] => [uri] => http://www.example.com/ [timed_out] => [blocked] => 1 [eof] => ) NOTES
Note This function does NOT work on sockets created by the Socket extension. SEE ALSO
get_headers(3), $http_response_header. PHP Documentation Group STREAM_GET_META_DATA(3)

Check Out this Related Man Page

GET_HEADERS(3)								 1							    GET_HEADERS(3)

get_headers - Fetches all the headers sent by the server in response to a HTTP request

SYNOPSIS
array get_headers (string $url, [int $format]) DESCRIPTION
get_headers(3) returns an array with the headers sent by the server in response to a HTTP request. PARAMETERS
o $url - The target URL. o $format - If the optional $format parameter is set to non-zero, get_headers(3) parses the response and sets the array's keys. RETURN VALUES
Returns an indexed or associative array with the headers, or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.1.3 | | | | | | | This function now uses the default stream con- | | | text, which can be set/changed with the | | | stream_context_set_default(3) function. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 get_headers(3) example <?php $url = 'http://www.example.com'; print_r(get_headers($url)); print_r(get_headers($url, 1)); ?> The above example will output something similar to: 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 ) Example #2 get_headers(3) using HEAD example <?php // By default get_headers uses a GET request to fetch the headers. If you // want to send a HEAD request instead, you can do so using a stream context: stream_context_set_default( array( 'http' => array( 'method' => 'HEAD' ) ) ); $headers = get_headers('http://example.com'); ?> SEE ALSO
apache_request_headers(3). PHP Documentation Group GET_HEADERS(3)
Man Page