mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-23 04:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@297028 c90b9560-bf6c-de11-be94-00142212c4b1
265 lines
7.1 KiB
XML
265 lines
7.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.stream-get-meta-data" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>stream_get_meta_data</refname>
|
|
<refpurpose>Retrieves header/meta data from streams/file pointers</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>stream_get_meta_data</methodname>
|
|
<methodparam><type>resource</type><parameter>stream</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Returns information about an existing <parameter>stream</parameter>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>stream</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The stream can be any stream created by <function>fopen</function>,
|
|
<function>fsockopen</function> and <function>pfsockopen</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
The result array contains the following items:
|
|
</para>
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>
|
|
<literal>timed_out</literal> (bool) - &true; if the stream
|
|
timed out while waiting for data on the last call to
|
|
<function>fread</function> or <function>fgets</function>.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>blocked</literal> (bool) - &true; if the stream is
|
|
in blocking IO mode. See <function>stream_set_blocking</function>.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>eof</literal> (bool) - &true; if the stream has reached
|
|
end-of-file. Note that for socket streams this member can be &true;
|
|
even when <literal>unread_bytes</literal> is non-zero. To
|
|
determine if there is more data to be read, use
|
|
<function>feof</function> instead of reading this item.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>unread_bytes</literal> (int) - the number of bytes
|
|
currently contained in the PHP's own internal buffer.
|
|
</para>
|
|
<note>
|
|
<simpara>
|
|
You shouldn't use this value in a script.
|
|
</simpara>
|
|
</note>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>stream_type</literal> (string) - a label describing
|
|
the underlying implementation of the stream.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>wrapper_type</literal> (string) - a label describing
|
|
the protocol wrapper implementation layered over the stream.
|
|
See <xref linkend="wrappers"/> for more information about wrappers.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>wrapper_data</literal> (mixed) - wrapper specific
|
|
data attached to this stream. See <xref linkend="wrappers"/> for
|
|
more information about wrappers and their wrapper data.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>filters</literal> (array) - and array containing
|
|
the names of any filters that have been stacked onto this stream.
|
|
Documentation on filters can be found in the
|
|
<link linkend="filters">Filters appendix</link>.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>mode</literal> (string) - the type of access required for
|
|
this stream (see Table 1 of the <link
|
|
linkend="function.fopen">fopen()</link> reference)
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>seekable</literal> (bool) - whether the current stream can
|
|
be seeked.
|
|
</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>
|
|
<literal>uri</literal> (string) - the URI/filename associated with this
|
|
stream.
|
|
</para>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.0.0</entry>
|
|
<entry>
|
|
The following entries were added in the returned array:
|
|
<literal>mode</literal>, <literal>seekable</literal>,
|
|
and <literal>uri</literal>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4.3.0</entry>
|
|
<entry>
|
|
The following entries were added in the returned array:
|
|
<literal>stream_type</literal>, <literal>wrapper_type</literal>,
|
|
<literal>wrapper_data</literal>, and <literal>filters</literal>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4.3.0</entry>
|
|
<entry>
|
|
<function>socket_get_status</function> is an alias for this function.
|
|
Prior to PHP 4.3.0, it was used to retrieve the first four items, for
|
|
<emphasis>socket based streams only</emphasis>.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>stream_get_meta_data</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?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);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
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] =>
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>This function does NOT work on sockets created by the <link
|
|
linkend="ref.sockets">Socket extension</link>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>get_headers</function></member>
|
|
<member><link linkend="reserved.variables.httpresponseheader">$http_response_header</link></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|