The BZIP2 function is used to transparently read and write bzip2 (. bz2) Compressed files.
This module uses the functions in the»BZIP2 Library of Julian Seward. This module requires BZIP2/LIBBZIP2 version >= 1.0.x.
PHP BZIP2 support is not turned on by default. Compile PHP requires--with-bz2[=dir] configuration options to activate BZIP2 support.
The following example opens a temporary file and writes a test string, and then outputs the contents of the file:
Example #1 bzip2 Small Example
<?php $filename = "/tmp/testfile.bz2"; $str = "This is a test string.\n"; Open a file for writing $bz = Bzopen ($filename, "w"); Write string to file bzwrite ($BZ, $str); Close file bzclose ($BZ); Open file for reading $BZ = Bzopen ($filename, "R"); Reads 10 characters of Echo Bzread ($BZ, ten); Output until the end of the file (or 1024 characters later), and close. Echo Bzread ($BZ); Bzclose ($BZ);? >
Related functions:
bzclose-Close a bzip2 file
bzcompress-to compress a string into BZIP2 encoded data
bzdecompress-extracting data encoded by BZIP2
bzerrno-returns a bzip2 error code
bzerror-returns an array containing the BZIP2 error number and the error string
bzerrstr-returns an bzip2 error string
bzflush-Force write data to all write buffers
bzopen-open a file that has been bzip2 compressed
BZREAD-BZIP2 file binary securely read
bzwrite-binary securely writes bzip2 files