Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 17125 программистов и 1834 робота. Сейчас ищут 1574 программиста ...
Examples
Вернуться к: File_Archive
Examples
Examples – Some simple usage examples
Here we simply take a tar archive called archive.tar and extract its contents to the folder
<?php
require_once "File/Archive.php";
File_Archive::extract('archive.tar/', 'output');
?>
Send a zip archive containing the content of a tar file to the standard output
<?php
require_once "File/Archive.php";
File_Archive::extract(
//The content of archive.tar appears in the root folder (default argument)
'archive.tar/',
//And is written to ...
File_Archive::toArchive( // ... a zip archive
'archive.zip', // called archive.zip
File_Archive::toOutput() // that will be sent to the standard output
)
);
?>
Extracting a file from an archive
Use extract() to get files out of an archive. When specifying the file to extract, make sure to use the archive name as first folder.
<?php
require_once "File/Archive.php";
File_Archive::extract(
'archive.tar/inner.tgz/file.txt',
File_Archive::toOutput()
);
?>
Вернуться к: File_Archive