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:
- compress.zlib://
- compress.bzip2://
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.
Attribute | Supported |
---|---|
Restricted by allow_url_fopen | No |
Allows Reading | Yes |
Allows Writing | Yes |
Allows Appending | Yes |
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 |
ZIP extension registers zip: wrapper.
- Функция file://() - Доступ к локальной файловой системе
- Функция http://() - Доступ к URL-адресам по протоколу HTTP(s)
- Функция ftp://() - Доступ к URL-адресам по протоколу FTP(s)
- Функция php://() - Доступ к различным потокам ввода-вывода
- Функция zlib://() - Сжатые потоки
- Функция data://() - Схема Data (RFC 2397)
- Функция glob://() - Нахождение путей, соответствующих шаблону
- Функция phar://() - PHP архив
- Функция ssh2://() - Secure Shell 2
- Функция rar://() - RAR
- Функция ogg://() - Аудио потоки
- Функция expect://() - Потоки для взаимодействия с процессами
Коментарии
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.
One-liners to gzip and ungzip a file:
copy('file.txt', 'compress.zlib://' . 'file.txt.gz');
copy('compress.zlib://' . 'file.txt.gz', 'file.txt');