<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Binär-sicheres Lesen aus einer bzip2-Datei</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.bzopen.html">bzopen</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.bzwrite.html">bzwrite</a></div> <div class="up"><a href="ref.bzip2.html">Bzip2 Funktionen</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.bzread" class="refentry"> <div class="refnamediv"> <h1 class="refname">bzread</h1> <p class="verinfo">(PHP 4 >= 4.0.4, PHP 5)</p><p class="refpurpose"><span class="refname">bzread</span> — <span class="dc-title">Binär-sicheres Lesen aus einer bzip2-Datei</span></p> </div> <div class="refsect1 description" id="refsect1-function.bzread-description"> <h3 class="title">Beschreibung</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>bzread</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$bz</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$length</code><span class="initializer"> = 1024</span></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>bzread()</strong></span> liest Daten vom übergebenen bzip2-Dateizeiger. </p> <p class="para"> Das Lesen wird beendet, wenn <code class="parameter">length</code> (unkomprimierte) Bytes gelesen wurden oder das Ende der Datei (EOF) erreicht ist, je nachdem, welcher Fall zuerst auftritt. </p> </div> <div class="refsect1 parameters" id="refsect1-function.bzread-parameters"> <h3 class="title">Parameter-Liste</h3> <p class="para"> <dl> <dt> <code class="parameter">bz</code></dt> <dd> <p class="para"> Der Dateizeiger. Es muss ein valider Zeiger sein und auf eine Datei zeigen, die erfolgreich mittels <span class="function"><a href="function.bzopen.html" class="function">bzopen()</a></span> geöffnet wurde. </p> </dd> <dt> <code class="parameter">length</code></dt> <dd> <p class="para"> Wenn nichts angegeben ist, liest <span class="function"><strong>bzread()</strong></span> 1024 (unkomprimierte) Bytes auf einmal. Maximal 8192 unkomprimierte Bytes können auf einmal gelesen werden. </p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.bzread-returnvalues"> <h3 class="title">Rückgabewerte</h3> <p class="para"> Gibt die unkomprimierten Daten oder im Fehlerfall <strong><code>FALSE</code></strong> zurück. </p> </div> <div class="refsect1 examples" id="refsect1-function.bzread-examples"> <h3 class="title">Beispiele</h3> <p class="para"> <div class="example" id="example-616"> <p><strong>Beispiel #1 <span class="function"><strong>bzread()</strong></span>-Beispiel</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />$file </span><span style="color: #007700">= </span><span style="color: #DD0000">"/tmp/foo.bz2"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$bz </span><span style="color: #007700">= </span><span style="color: #0000BB">bzopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">, </span><span style="color: #DD0000">"r"</span><span style="color: #007700">) or die(</span><span style="color: #DD0000">"Konnte </span><span style="color: #0000BB">$file</span><span style="color: #DD0000"> nicht öffnen"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$decompressed_file </span><span style="color: #007700">= </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />while (!</span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$bz</span><span style="color: #007700">)) {<br /> </span><span style="color: #0000BB">$decompressed_file </span><span style="color: #007700">.= </span><span style="color: #0000BB">bzread</span><span style="color: #007700">(</span><span style="color: #0000BB">$bz</span><span style="color: #007700">, </span><span style="color: #0000BB">4096</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">bzclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$bz</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"Der Inhalt von </span><span style="color: #0000BB">$file</span><span style="color: #DD0000"> ist: <br />\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$decompressed_file</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.bzread-seealso"> <h3 class="title">Siehe auch</h3> <p class="para"> <ul class="simplelist"> <li class="member"><span class="function"><a href="function.bzwrite.html" class="function" rel="rdfs-seeAlso">bzwrite()</a> - Binär-sicheres Schreiben einer bzip2-Datei</span></li> <li class="member"><span class="function"><a href="function.feof.html" class="function" rel="rdfs-seeAlso">feof()</a> - Prüft, ob ein Dateizeiger am Ende der Datei steht</span></li> <li class="member"><span class="function"><a href="function.bzopen.html" class="function" rel="rdfs-seeAlso">bzopen()</a> - Öffnet eine bzip2-komprimierte Datei</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.bzopen.html">bzopen</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.bzwrite.html">bzwrite</a></div> <div class="up"><a href="ref.bzip2.html">Bzip2 Funktionen</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>