ZipArchive::getFromName

(PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.1.0)

ZipArchive::getFromName — 이름을 사용하여 항목 내용을 반환합니다.


설명

public ZipArchive::getFromName(string $name, int $len = 0, int $flags = 0): string|false

이름을 사용하여 항목 내용을 반환합니다.


매개변수

name
항목 이름
len
항목에서 읽을 길이입니다. 0이면 전체 항목을 읽습니다.
flags
항목을 찾는 데 사용할 플래그입니다. 다음 값은 OR될 수 있습니다.
  • ZipArchive::FL_UNCHANGED
  • ZipArchive::FL_COMPRESSED
  • ZipArchive::FL_NOCASE

반환 값

성공하면 항목의 내용을 반환하고 실패하면 false를 반환합니다.


Examples

예 #1 파일 내용 가져오기

                  
<?php
$zip = new ZipArchive;
if ($zip->open('test1.zip') === TRUE) {
    echo $zip->getFromName('testfromfile.php');
    $zip->close();
} else {
    echo 'failed';
}
?>
                  
                

예 #2 zip 항목에서 이미지 변환

                  
<?php
$z = new ZipArchive();
if ($z->open(dirname(__FILE__) . '/test_im.zip')) {
    $im_string = $z->getFromName("pear_item.gif");
    $im = imagecreatefromstring($im_string);
    imagepng($im, 'b.png');
}
?>
                  
                

기타