PHP8 ZipArchive::getFromIndex

2024-02-26 14:05 更新

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

ZipArchive::getFromIndex — 使用其索引返回條目?jī)?nèi)容

說明

public ZipArchive::getFromIndex(int $index, int $len = 0, int $flags = 0): string|false

使用其索引返回條目?jī)?nèi)容。

參數(shù) 

index

條目的索引

len

要從條目中讀取的長(zhǎng)度。如果 ,則 讀取整個(gè)條目。0

flags

用于打開存檔的標(biāo)志。以下值可能 被 ORed 到它。

  • ZipArchive::FL_UNCHANGED

  • ZipArchive::FL_COMPRESSED

返回值 

返回 success 條目的內(nèi)容 或者在失敗時(shí)返回 false。

示例 

示例 #1 獲取文件內(nèi)容

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

參見 

  • ZipArchive::getFromName() - 使用其名稱返回條目?jī)?nèi)容


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)