stream_get_meta_data
Description
The stream_get_meta_data of Stream for PHP retrieves header/meta data from streams/file pointers.
Syntax
stream_get_meta_data(
resource $stream
): arrayParameters
stream
The stream can be any stream created by fopen(), fsockopen(), pfsockopen(), and stream_socket_client().
Return
The result array contains the following items:
| Item | Description |
|---|---|
| timed_out (bool) | TRUE if the stream timed out while waiting for data on the last call to fread() or fgets(). |
| blocked (bool) | TRUE if the stream is in blocking IO mode. See stream_set_blocking(). |
| 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() instead of reading this item. |
| wrapper_data (mixed) | wrapper specific data attached to this stream. See Supported Protocols and Wrappers for more information about wrappers and their wrapper data. |
| wrapper_type (string) | a label describing the protocol wrapper implementation layered over the stream. See Supported Protocols and Wrappers for more information about wrappers. |
| stream_type (string) | a label describing the underlying implementation of the stream. |
| mode (string) | the type of access required for this stream. |
| 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. |
| seekable (bool) | whether the current stream can be seeked. |
| uri (string) | the URI/filename associated with this stream. |
Examples
1 · stream · fopen
<?
$filename = "https://www.php.net/";
$mode = "r";
$stream = fopen($filename, $mode);
$return = stream_get_meta_data($stream);
print_r($return);
fclose($stream);
Array
(
[crypto] => Array
(
[protocol] => TLSv1.3
[cipher_name] => TLS_AES_256_GCM_SHA384
[cipher_bits] => 256
[cipher_version] => TLSv1.3
)
[timed_out] =>
[blocked] => 1
[eof] =>
[wrapper_data] => Array
(
[0] => HTTP/1.1 200 OK
[1] => Date: Wed, 22 Jul 2026 14:18:46 GMT
[2] => Content-Type: text/html; charset=utf-8
[3] => Connection: close
[4] => Vary: Accept-Encoding
[5] => Server: BunnyCDN-GA1-1364
[6] => CDN-PullZone: 5992589
[7] => CDN-RequestCountryCode: US
[8] => Cache-Control: public, max-age=300
[9] => Content-Language: en
[10] => Last-Modified: Wed, 22 Jul 2026 14:10:27 GMT
[11] => Set-Cookie: LAST_NEWS=1784729926; expires=Thu, 22 Jul 2027 14:18:46 GMT; Max-Age=31536000; path=/; domain=.php.net
[12] => Strict-Transport-Security: max-age=15768000
[13] => Permissions-Policy: interest-cohort=()
[14] => X-Frame-Options: SAMEORIGIN
[15] => Link: <https://www.php.net/index>; rel=shorturl
[16] => CDN-ProxyVer: 1.58
[17] => CDN-RequestPullSuccess: True
[18] => CDN-RequestPullCode: 200
[19] => CDN-CachedAt: 07/22/2026 14:18:46
[20] => CDN-EdgeStorageId: 1364
[21] => CDN-RequestId: da1f6db0f7107bf2074fa65e58aff385
[22] => CDN-Cache: MISS
[23] => CDN-Status: 200
[24] => CDN-RequestTime: 0
)
[wrapper_type] => http
[stream_type] => tcp_socket/ssl
[mode] => r
[unread_bytes] => 7320
[seekable] =>
[uri] => https://www.php.net/
)
2 · stream · stream_socket_client
<? $address = "ssl://osbo.com:443"; $stream = stream_socket_client($address); $return = stream_get_meta_data($stream); print_r($return);
Array
(
[crypto] => Array
(
[protocol] => TLSv1.3
[cipher_name] => TLS_AES_256_GCM_SHA384
[cipher_bits] => 256
[cipher_version] => TLSv1.3
)
[timed_out] =>
[blocked] => 1
[eof] =>
[stream_type] => tcp_socket/ssl
[mode] => r+
[unread_bytes] => 0
[seekable] =>
[uri] => ssl://osbo.com:443
)
Links
Stream
- stream_bucket_append
- stream_bucket_make_writeable
- stream_bucket_new
- stream_bucket_prepend
- stream_context_create
- stream_context_get_default
- stream_context_get_options
- stream_context_get_params
- stream_context_set_default
- stream_context_set_option
- stream_context_set_options
- stream_context_set_params
- stream_copy_to_stream
- stream_filter_append
- stream_filter_prepend
- stream_filter_register
- stream_filter_remove
- stream_get_contents
- stream_get_filters
- stream_get_line
- stream_get_transports
- stream_get_wrappers
- stream_is_local
- stream_isatty
- stream_notification_callback
- stream_register_wrapper
- stream_resolve_include_path
- stream_select
- stream_set_blocking
- stream_set_chunk_size
- stream_set_read_buffer
- stream_set_timeout
- stream_set_write_buffer
- stream_socket_accept
- stream_socket_client
- stream_socket_enable_crypto
- stream_socket_get_name
- stream_socket_pair
- stream_socket_recvfrom
- stream_socket_sendto
- stream_socket_server
- stream_socket_shutdown
- stream_supports_lock
- stream_wrapper_register
- stream_wrapper_restore
- stream_wrapper_unregister