首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

ZipArchive::getFromName

(PHP 5 >= 5.2.0, PHP 7, PECL zip >= 1.1.0)

ZipArchive::getFromName - 使用其名称返回条目内容

描述

代码语言:javascript
复制
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 or FALSE 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 →

扫码关注腾讯云开发者

领取腾讯云代金券