Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<ZipArchive::getStreamIndexZipArchive::isCompressionMethodSupported>
^ZipArchiveLast updated: Mon, 26 Oct 2026

ZipArchive::getStreamName

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

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

Description

public function 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.

Parameters

name

The name of the entry to use.

flags

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

Return Values

Returns a file pointer (resource) on success or false on failure.

Examples

Example #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);
}
?>

See Also


<ZipArchive::getStreamIndexZipArchive::isCompressionMethodSupported>
^ZipArchiveLast updated: Mon, 26 Oct 2026