略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: ZipArchive::getStreamName

2024-11-13

ZipArchive::getStreamName

(PHP 8 >= 8.2.0, PECL zip >= 1.20.0)

ZipArchive::getStreamNameGet a file handler to the entry defined by its name (read only)

说明

public ZipArchive::getStreamName(string $name, int $flags = 0): resource|false

Get a file handler to the entry defined by its name. For now, it only supports read operations.

参数

name

The name of the entry to use.

flags

If flags is set to ZipArchive::FL_UNCHANGED, the original unchanged stream is returned.

返回值

Returns a file pointer (resource) on success 或者在失败时返回 false.

范例

示例 #1 Get the entry contents with fread() and store it

<?php
$contents 
'';
$z = new ZipArchive();
if (
$z->open('test.zip')) {
    
$fp $z->getStreamName('test'ZipArchive::FL_UNCHANGED);
    if(!
$fp) die($z->getStatusString());

    echo 
stream_get_contents($fp);

    
fclose($fp);
}
?>

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/ziparchive.getstreamname.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3