<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.stream.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.stream-get-meta-data.php',
    1 => 'stream_get_meta_data',
    2 => 'Retrieves header/meta data from streams/file pointers',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'Stream Функції',
  ),
  'prev' => 
  array (
    0 => 'function.stream-get-line.php',
    1 => 'stream_get_line',
  ),
  'next' => 
  array (
    0 => 'function.stream-get-transports.php',
    1 => 'stream_get_transports',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/stream/functions/stream-get-meta-data.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-get-meta-data" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_get_meta_data</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_get_meta_data</span> &mdash; <span class="dc-title">Retrieves header/meta data from streams/file pointers</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-get-meta-data-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_get_meta_data</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$stream</code></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Returns information about an existing <code class="parameter">stream</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-get-meta-data-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code></dt>
     <dd>
      <p class="para">
       The stream can be any stream created by <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>,
       <span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span> <span class="function"><a href="function.pfsockopen.php" class="function">pfsockopen()</a></span> and <span class="function"><a href="function.stream-socket-client.php" class="function">stream_socket_client()</a></span>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-get-meta-data-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   The result array contains the following items:
  </p>
  <ul class="itemizedlist">
   <li class="listitem">
    <p class="para">
     <code class="literal">timed_out</code> (bool) - <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if the stream
     timed out while waiting for data on the last call to
     <span class="function"><a href="function.fread.php" class="function">fread()</a></span> or <span class="function"><a href="function.fgets.php" class="function">fgets()</a></span>.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">blocked</code> (bool) - <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if the stream is
     in blocking IO mode. See <span class="function"><a href="function.stream-set-blocking.php" class="function">stream_set_blocking()</a></span>.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">eof</code> (bool) - <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if the stream has reached
     end-of-file.  Note that for socket streams this member can be <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>
     even when <code class="literal">unread_bytes</code> is non-zero.  To
     determine if there is more data to be read, use
     <span class="function"><a href="function.feof.php" class="function">feof()</a></span> instead of reading this item.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">unread_bytes</code> (int) - the number of bytes
     currently contained in the PHP&#039;s own internal buffer.
    </p>
    <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
     <span class="simpara">
      You shouldn&#039;t use this value in a script.
     </span>
    </p></blockquote>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">stream_type</code> (string) - a label describing
     the underlying implementation of the stream.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">wrapper_type</code> (string) - a label describing
     the protocol wrapper implementation layered over the stream.
     See <a href="wrappers.php" class="xref">Підтримувані протоколи та обгортки</a> for more information about wrappers.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">wrapper_data</code> (mixed) - wrapper specific
     data attached to this stream.  See <a href="wrappers.php" class="xref">Підтримувані протоколи та обгортки</a> for
     more information about wrappers and their wrapper data.
    </p>
   </li>
   
   <li class="listitem">
    <p class="para">
     <code class="literal">mode</code> (string) - the type of access required for
     this stream (see Table 1 of the <a href="function.fopen.php" class="link">fopen()</a> reference)
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">seekable</code> (bool) - whether the current stream can
     be seeked.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">uri</code> (string) - the URI/filename associated with this
     stream.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     <code class="literal">crypto</code> (array) - the TLS connection metadata for this
     stream. (Note: Only provided when the resource&#039;s stream uses TLS.)
    </p>
   </li>
  </ul>
 </div>


 <div class="refsect1 examples" id="refsect1-function.stream-get-meta-data-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>stream_get_meta_data()</strong></span> example using <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span> with http</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$url </span><span style="color: #007700">= </span><span style="color: #DD0000">'http://www.example.com/'</span><span style="color: #007700">;<br /><br />if (!</span><span style="color: #0000BB">$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$url</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">)) {<br />    </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #DD0000">"Unable to open URL (</span><span style="color: #0000BB">$url</span><span style="color: #DD0000">)"</span><span style="color: #007700">, </span><span style="color: #0000BB">E_USER_ERROR</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">$meta </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_get_meta_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$meta</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Поданий вище приклад виведе щось
схоже на:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">array(10) {
  &#039;timed_out&#039; =&gt;
  bool(false)
  &#039;blocked&#039; =&gt;
  bool(true)
  &#039;eof&#039; =&gt;
  bool(false)
  &#039;wrapper_data&#039; =&gt;
  array(13) {
    [0] =&gt;
    string(15) &quot;HTTP/1.1 200 OK&quot;
    [1] =&gt;
    string(11) &quot;Age: 244629&quot;
    [2] =&gt;
    string(29) &quot;Cache-Control: max-age=604800&quot;
    [3] =&gt;
    string(38) &quot;Content-Type: text/html; charset=UTF-8&quot;
    [4] =&gt;
    string(35) &quot;Date: Sat, 20 Nov 2021 18:17:57 GMT&quot;
    [5] =&gt;
    string(24) &quot;Etag: &quot;3147526947+ident&quot;&quot;
    [6] =&gt;
    string(38) &quot;Expires: Sat, 27 Nov 2021 18:17:57 GMT&quot;
    [7] =&gt;
    string(44) &quot;Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT&quot;
    [8] =&gt;
    string(22) &quot;Server: ECS (chb/0286)&quot;
    [9] =&gt;
    string(21) &quot;Vary: Accept-Encoding&quot;
    [10] =&gt;
    string(12) &quot;X-Cache: HIT&quot;
    [11] =&gt;
    string(20) &quot;Content-Length: 1256&quot;
    [12] =&gt;
    string(17) &quot;Connection: close&quot;
  }
  &#039;wrapper_type&#039; =&gt;
  string(4) &quot;http&quot;
  &#039;stream_type&#039; =&gt;
  string(14) &quot;tcp_socket/ssl&quot;
  &#039;mode&#039; =&gt;
  string(1) &quot;r&quot;
  &#039;unread_bytes&#039; =&gt;
  int(1256)
  &#039;seekable&#039; =&gt;
  bool(false)
  &#039;uri&#039; =&gt;
  string(23) &quot;http://www.example.com/&quot;
}</pre>
</div>
    </div>
   </div>
   <div class="example" id="example-2">
    <p><strong>Приклад #2 <span class="function"><strong>stream_get_meta_data()</strong></span> example using <span class="function"><a href="function.stream-socket-client.php" class="function">stream_socket_client()</a></span> with https</strong></p>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$streamContext </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">(<br />    [<br />        </span><span style="color: #DD0000">'ssl' </span><span style="color: #007700">=&gt; [<br />            </span><span style="color: #DD0000">'capture_peer_cert' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">true</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">'capture_peer_cert_chain' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">true</span><span style="color: #007700">,<br />            </span><span style="color: #DD0000">'disable_compression' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">true</span><span style="color: #007700">,<br />        ],<br />    ]<br />);<br /><br /></span><span style="color: #0000BB">$client </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_socket_client</span><span style="color: #007700">(<br />    </span><span style="color: #DD0000">'ssl://www.example.com:443'</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">$errorNumber</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">$errorDescription</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">40</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">STREAM_CLIENT_CONNECT</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">$streamContext<br /></span><span style="color: #007700">);<br /><br /><br /></span><span style="color: #0000BB">$meta </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_get_meta_data</span><span style="color: #007700">(</span><span style="color: #0000BB">$client</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$meta</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Поданий вище приклад виведе щось
схоже на:</p></div>
    <div class="example-contents screen">
     <div class="examplescode"><pre class="examplescode">array(8) {
  &#039;crypto&#039; =&gt;
  array(4) {
    &#039;protocol&#039; =&gt;
    string(7) &quot;TLSv1.3&quot;
    &#039;cipher_name&#039; =&gt;
    string(22) &quot;TLS_AES_256_GCM_SHA384&quot;
    &#039;cipher_bits&#039; =&gt;
    int(256)
    &#039;cipher_version&#039; =&gt;
    string(7) &quot;TLSv1.3&quot;
  }
  &#039;timed_out&#039; =&gt;
  bool(false)
  &#039;blocked&#039; =&gt;
  bool(true)
  &#039;eof&#039; =&gt;
  bool(false)
  &#039;stream_type&#039; =&gt;
  string(14) &quot;tcp_socket/ssl&quot;
  &#039;mode&#039; =&gt;
  string(2) &quot;r+&quot;
  &#039;unread_bytes&#039; =&gt;
  int(0)
  &#039;seekable&#039; =&gt;
  bool(false)
}</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-get-meta-data-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">This function does NOT work on sockets created by the <a href="ref.sockets.php" class="link">Socket extension</a>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-get-meta-data-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.get-headers.php" class="function" rel="rdfs-seeAlso">get_headers()</a> - Fetches all the headers sent by the server in response to an HTTP request</span></li>
    <li><a href="reserved.variables.httpresponseheader.php" class="link">$http_response_header</a></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>