downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

bzwrite> <bzopen
[edit] Last updated: Tue, 21 May 2013

view this page in

bzread

(PHP 4 >= 4.0.4, PHP 5)

bzreadEsegue la lettura binaria di un file bzip2

Descrizione

string bzread ( resource $bz [, int $lunghezza ] )

bzread() legge fino a lunghezza byte dal puntatore bzip2 specificato da bz. La pettura termina quando lunghezza byte (decompressi) sono stati letti o quando viene raggiunto l'EOF. Se il parametro opzionale lunghezza è omesso, bzread() leggerà 1024 byte (decompressi) ogni volta.

Example #1 Esempio di bzread()

<?php

$file 
"/tmp/foo.bz2";
$bz bzopen($file"r") or die("Non ho potuto aprire $file");

$File_decompresso '';
while (!
feof($bz)) {
   
$file_decompresso .= bzread($bz4096);
}
bzclose($bz);

echo 
"Il contenuto di $file è: <br />\n";
echo 
$file_decompresso;

?>

Vedere anche bzwrite(), feof() e bzopen().



add a note add a note User Contributed Notes bzread - [1 notes]
up
1
user@anonymous
1 year ago
Make sure you check for bzerror while looping through a bzfile. bzread will not detect a compression error and can continue forever even at the cost of 100% cpu.

$fh = bzopen('file.bz2','r');
while(!feof($fh)) {
  $buffer = bzread($fh);
  if($buffer === FALSE) die('Read problem');
  if(bzerror($fh) !== 0) die('Compression Problem');
}
bzclose($fh);

 
show source | credits | sitemap | contact | advertising | mirror sites