• PHP Video Tutorials

PHP - bzip2 Functions



The bzip2 functions can be used to transparently read and write bzip2 (.bz2) compressed files.

The Bzip2 module can use the functions of the bzip2 library by Julian Seward. This module can require bzip2/libbzip2 version >= 1.0.x.

Bzip2 can support in PHP is not enabled by default. We need to use them --with-bz2[=DIR] configuration option when compiling PHP to enable bzip2 support.

Example

<?php
   $filename = "/tmp/testfile.bz2";
   $str = "This is a test string.\n";
   $bz = bzopen($filename, "w");
   bzwrite($bz, $str);
   bzclose($bz);
   $bz = bzopen($filename, "r");
   echo bzread($bz, 10);
   echo bzread($bz);
   bzclose($bz);
?>  

Predefined Constants

This extension has no constants defined.

Sr.No Function & Description
1

bzclose()

This Function can close a bzip2 file.

2

bzcompress()

This Function can compress a string into bzip2 encoded data.

3

bzdecompress()

This Function can decompress the bzip2 encoded data.

4

bzerrno()

This Function can return a bzip2 error number.

5

bzerror()

This Function can return a bzip2 error number and error string in an array.

6

bzerrstr()

This Function can return a bzip2 error string.

7

bzflush()

This Function can force a write of all buffered data.

8

bzopen()

This Function can open a bzip2 compressed file.

9

bzread()

This Function is a binary-safe bzip2 file read.

10

bzwrite()

This Function is a binary-safe bzip2 file write.

php_function_reference.htm
Advertisements