<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.stream-get-contents.php',
    1 => 'stream_get_contents',
    2 => 'Reads remainder of a stream into a string',
  ),
  'up' => 
  array (
    0 => 'ref.stream.php',
    1 => 'Stream-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.stream-filter-remove.php',
    1 => 'stream_filter_remove',
  ),
  'next' => 
  array (
    0 => 'function.stream-get-filters.php',
    1 => 'stream_get_filters',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/stream/functions/stream-get-contents.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.stream-get-contents" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">stream_get_contents</h1> 
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">stream_get_contents</span> &mdash; <span class="dc-title">Reads remainder of a stream into a string</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.stream-get-contents-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>stream_get_contents</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="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$length</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code><span class="initializer"> = -1</span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment"> 
   Identical to <span class="function"><a href="function.file-get-contents.php" class="function">file_get_contents()</a></span>, except that
   <span class="function"><strong>stream_get_contents()</strong></span> operates on an already open
   stream resource and returns the remaining contents in a string, up to
   <code class="parameter">length</code> bytes and starting at the specified
   <code class="parameter">offset</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.stream-get-contents-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code> (<span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>)</dt>
     <dd>
      <p class="para">
       A stream resource (e.g. returned from <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>)
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code> (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)</dt>
     <dd>
      <p class="para">
       The maximum bytes to read. Defaults to <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> (read all the remaining
       buffer).
      </p>
     </dd>
    
    
     <dt><code class="parameter">offset</code> (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)</dt>
     <dd>
      <p class="para">
       Seek to the specified offset before reading. If this number is negative,
       no seeking will occur and reading will start from the current position.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.stream-get-contents-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Returns a stringBei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben..
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.stream-get-contents-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">length</code> is now nullable.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.stream-get-contents-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>stream_get_contents()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">$stream </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.example.com'</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">)) {<br />    </span><span style="color: #FF8000">// print all the page starting at the offset 10<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">stream_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">, -</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">);<br />}<br /><br /><br />if (</span><span style="color: #0000BB">$stream </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.example.net'</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">)) {<br />    </span><span style="color: #FF8000">// print the first 5 bytes<br />    </span><span style="color: #007700">echo </span><span style="color: #0000BB">stream_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$stream</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.stream-get-contents-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">Diese Funktion ist
binärsicher.</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    When specifying a <code class="parameter">length</code> value other than <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, this function will
    immediately allocate an internal buffer of that size even if the
    actual contents are significantly shorter.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.stream-get-contents-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.fgets.php" class="function" rel="rdfs-seeAlso">fgets()</a> - Liest die Zeile von der Position des Dateizeigers</span></li>
    <li><span class="function"><a href="function.fread.php" class="function" rel="rdfs-seeAlso">fread()</a> - Liest Bin&auml;rdaten aus einer Datei</span></li>
    <li><span class="function"><a href="function.fpassthru.php" class="function" rel="rdfs-seeAlso">fpassthru()</a> - Gibt alle verbleibenden Daten eines Dateizeigers aus</span></li>
   </ul>
  </p>
 </div>

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