略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: RarArchive::getEntry

2024-11-15

RarArchive::getEntry

rar_entry_get

(PECL rar >= 2.0.0)

RarArchive::getEntry -- rar_entry_getGet entry object from the RAR archive

说明

面向对象风格 (method):

public RarArchive::getEntry(string $entryname): RarEntry|false

过程化风格:

rar_entry_get(RarArchive $rarfile, string $entryname): RarEntry|false

Get entry object (file or directory) from the RAR archive.

注意:

You can also get entry objects using RarArchive::getEntries().

Note that a RAR archive can have multiple entries with the same name; this method will retrieve only the first.

参数

rarfile

A RarArchive object, opened with rar_open().

entryname

Path to the entry within the RAR archive.

注意:

The path must be the same returned by RarEntry::getName().

返回值

Returns the matching RarEntry object 或者在失败时返回 false.

范例

示例 #1 面向对象风格

<?php
$rar_arch 
RarArchive::open('solid.rar');
if (
$rar_arch === FALSE)
    die(
"Could not open RAR archive.");
$rar_entry $rar_arch->getEntry('tese.txt');
if (
$rar_entry === FALSE)
    die(
"Could not get such entry");
echo 
get_class($rar_entry)."\n";
echo 
$rar_entry;
$rar_arch->close();
?>

以上例程的输出类似于:

RarEntry
RarEntry for file "tese.txt" (23b93a7a)

示例 #2 过程化风格

<?php
$rar_arch 
rar_open('solid.rar');
if (
$rar_arch === FALSE)
    die(
"Could not open RAR archive.");
$rar_entry rar_entry_get($rar_arch'tese.txt');
if (
$rar_entry === FALSE)
    die(
"Could not get such entry");
echo 
get_class($rar_entry)."\n";
echo 
$rar_entry;
rar_close($rar_arch);
?>

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/rararchive.getentry.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3