The test code is as follows:
Copy codeThe Code is as follows:
<? Php
$ Fp = fopen ("http://www.sina.com.cn", 'R ');
$ Stream_meta = stream_get_meta_data ($ fp );
Print_r ($ stream_meta );
?>
The output on my local machine is as follows:
Array
(
[Wrapper_data] => Array
(
[0] => HTTP/1.0 200 OK
[1] => Date: Tue, 06 Dec 2011 10:08:11 GMT
[2] => Server: Apache
[3] => Last-Modified: Tue, 06 Dec 2011 10:07:12 GMT
[4] => Accept-Ranges: bytes
[5] => X-Powered-By: mod_xlayout/rc2
[6] => Cache-Control: max-age = 60
[7] => Expires: Tue, 06 Dec 2011 10:09:11 GMT
[8] => Vary: Accept-Encoding
[9] => X-UA-Compatible: IE = EmulateIE7
[10] => Content-Type: text/html
[11] => Age: 26
[12] => Content-Length: 675274
[13] => X-Cache: HIT from xd33-98.HP08040037.sina.com.cn
[14] => Connection: close
)
[Wrapper_type] => http
[Stream_type] => tcp_socket/ssl
[Mode] => r
[Unread_bytes] = & gt; 3759
[Seekable] =>
[Uri] => http://www.sina.com.cn
[Timed_out] =>
[Blocked] => 1
[Eof] =>
)
Description
Array stream_get_meta_data (int $ fp)
Returns information about an existing stream. It can be any stream created through fopen (), fsockopen () and pfsockopen. The returned array contains the following items:
Timed_out (bool)-TRUE if the stream times out when data is waiting in the last call of fread () or fgets.
Blocked (bool)-TRUE if the stream is in congested IO mode. See stream_set_blocking ().
Eof (bool)-TRUE if the stream reaches the end of the file. Note that the value of the socket stream can be TRUE even if unread_bytes is a non-zero value. To determine whether more data is readable, use feof () instead of reading this item.
Unread_bytes (int)-number of bytes in the current PHP internal buffer.
Note: Do not use this value in the script.
The following projects are newly added to PHP 4.3:
Stream_type (string)-A annotation that describes the underlying implementation of a stream.
Wrapper_type (string)-Annotation of the layer protocol encapsulation implementation that describes the stream.