ZipArchive::getFromName
(PHP 5 >= 5.2.0, PHP 7, PECL zip >= 1.1.0)
ZipArchive::getFromName - 使用其名称返回条目内容
描述
string ZipArchive::getFromName ( string $name [, int $length = 0 [, int $flags ]] )
使用其名称返回条目内容。
参数
name
条目的名称
length
从条目中读取的长度。如果为0,则读取整个条目。
flags
用于查找条目的标志。以下值可能是ORed。
ZipArchive::FL_UNCHANGED
ZipArchive::FL_COMPRESSED
ZipArchive::FL_NOCASE
Return Values Returns the contents of the entry on success orFALSE
on failure. ExamplesExample #1 Get the file contents<?php $zip = new ZipArchive; if ($zip->open('test1.zip') === TRUE) { echo $zip->getFromName('testfromfile.php'); $zip->close(); } else { echo 'failed'; } ?>Example #2 Convert an image from a zip entry<?php $z = new ZipArchive(); if ($z->open(dirname(__FILE__) . '/test_im.zip')) { $im_string = $z->getFromName("pear_item.gif"); $im = imagecreatefromstring($im_string); imagepng($im, 'b.png'); } ?>See Also
- ZipArchive::getFromIndex() - 使用索引返回条目内容
← ZipArchive::getFromIndex
ZipArchive::getNameIndex →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com