V. Bzip2 압축 함수
본 모듈은 Julian Seward님의 bzip2라이브러리의 함수로서 bzip2 (.bz2) 압축 파일을 읽고 쓸 수 있도록 해준다.
bzip2는 PHP에서 기본 설정만으로는 지원하지 않는다.
PHP를 컴파일할 때 --with-bz2[=DIR]과 같은 설정을 사용해야만 bzip2를 사용할 수 있다.
본 모듈은 bzip/libbzip2 >= 1.0.x 의 버전이 필요하다.
본 예제는 임시 파일을 열어 문자열을 기록한후 파일의 내용을 출력하게 된다.
예 1. 간단한 bzip2 예제 <?php
$filename = "/tmp/testfile.bz2";
$str = "This is a test string.\n";
// open 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");
// read 10 characters
print bzread($bz, 10);
// output until end of the file (or the next 1024 char) and close it.
print bzread($bz);
bzclose($bz);
?> |
|