Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 459

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Examples</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="bzip2.constants.html">Predefined Constants</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.bzip2.html">Bzip2 Functions</a></div>
 <div class="up"><a href="book.bzip2.html">Bzip2</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="bzip2.examples" class="chapter">
 <h1>Examples</h1>

 <p class="para">
  This example opens a temporary file and writes a test string to
  it, then prints out the contents of the file.
 </p>
 <div class="example" id="example-644">
  <p><strong>Example #1 Small bzip2 Example</strong></p>
  <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$filename&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"/tmp/testfile.bz2"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;a&nbsp;test&nbsp;string.\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;open&nbsp;file&nbsp;for&nbsp;writing<br /></span><span style="color: #0000BB">$bz&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">bzopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"w"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;write&nbsp;string&nbsp;to&nbsp;file<br /></span><span style="color: #0000BB">bzwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$bz</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$str</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;close&nbsp;file<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 /></span><span style="color: #FF8000">//&nbsp;open&nbsp;file&nbsp;for&nbsp;reading<br /></span><span style="color: #0000BB">$bz&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">bzopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;read&nbsp;10&nbsp;characters<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">bzread</span><span style="color: #007700">(</span><span style="color: #0000BB">$bz</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;output&nbsp;until&nbsp;end&nbsp;of&nbsp;the&nbsp;file&nbsp;(or&nbsp;the&nbsp;next&nbsp;1024&nbsp;char)&nbsp;and&nbsp;close&nbsp;it.&nbsp;&nbsp;<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">bzread</span><span style="color: #007700">(</span><span style="color: #0000BB">$bz</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 /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
  </div>

 </div>
</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="bzip2.constants.html">Predefined Constants</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="ref.bzip2.html">Bzip2 Functions</a></div>
 <div class="up"><a href="book.bzip2.html">Bzip2</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>