Supported Protocols and Wrappers
在线手册:中文 英文
PHP手册

zlib://

bzip2://

zip://

zlib:// -- bzip2:// -- zip://Compression Streams

说明

zlib: PHP 4.0.4 - PHP 4.2.3 (systems with fopencookie only)

compress.zlib:// and compress.bzip2:// PHP 4.3.0 and up

zlib: works like gzopen(), except that the stream can be used with fread() and the other filesystem functions. This is deprecated as of PHP 4.3.0 due to ambiguities with filenames containing ':' characters; use compress.zlib:// instead.

compress.zlib:// and compress.bzip2:// are equivalent to gzopen() and bzopen() respectively, and operate even on systems that do not support fopencookie.

ZIP extension registers zip: wrapper.

可选项

可选项

Wrapper Summary
Attribute Supported
Restricted by allow_url_fopen No
Allows Reading Yes
Allows Writing Yes (except zip://)
Allows Appending Yes (except zip://)
Allows Simultaneous Reading and Writing No
Supports stat() No, use the normal file:// wrapper to stat compressed files.
Supports unlink() No, use the normal file:// wrapper to unlink compressed files.
Supports rename() No
Supports mkdir() No
Supports rmdir() No


Supported Protocols and Wrappers
在线手册:中文 英文
PHP手册
PHP手册 - N: Compression Streams

用户评论:

alvaro at demogracia dot com (12-Apr-2011 03:41)

Example on how to read an entry from a ZIP archive (file "bar.txt" inside "./foo.zip"):

<?php

$fp
= fopen('zip://./foo.zip#bar.txt', 'r');
if(
$fp ){
    while( !
feof($fp) ){
        echo
fread($fp, 8192);
    }
   
fclose($fp);
}

?>

Also, apparently, the "zip:" wrapper does not allow writing as of PHP/5.3.6. You can read http://php.net/ziparchive-getstream for further reference since the underlying code is probably the same.

joshualross at gmail dot com (19-Aug-2007 08:24)

I had a difficult time finding how to use compress.zlib with an http resource so I thought I would post what I found
<?php
$file
= 'compress.zlib://http://www.example.com/myarchive.gz';
$fr = fopen($file, 'rb');
?>

Per the bugreport I found here (http://bugs.php.net/bug.php?id=29045)