W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
(PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL zip >= 1.1.0)
ZipArchive::getFromName — 使用其名稱返回條目內(nèi)容
public ZipArchive::getFromName(string $name, int $len = 0, int $flags = 0): string|false
使用條目名稱返回條目內(nèi)容。
name
條目的名稱
len
要從條目中讀取的長度。如果 ,則 讀取整個條目。0
flags
用于查找條目的標志。以下值可能 被 ORed。
ZipArchive::FL_UNCHANGED
ZipArchive::FL_COMPRESSED
ZipArchive::FL_NOCASE
返回 success 條目的內(nèi)容 或者在失敗時返回 false。
示例 #1 獲取文件內(nèi)容
<?php
$zip = new ZipArchive;
if ($zip->open('test1.zip') === TRUE) {
echo $zip->getFromName('testfromfile.php');
$zip->close();
} else {
echo 'failed';
}
?>
示例 #2 從 zip 條目轉(zhuǎn)換圖像
<?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');
}
?>
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: