codecamp

PHP8 RarEntry::getName

(PECL rar >= 0.1)

RarEntry::getName — 获取条目的名称

说明

public RarEntry::getName(): string

返回存档条目的名称(带路径)。

参数 

此函数没有参数。

返回值 

以字符串形式返回条目名称,如果 出错则返回 false。

更新日志 

版本说明
PECL rar 2.0.0从版本 2.0.0 开始,返回的字符串以 Unicode/UTF-8 编码。

示例 

示例 #1 RarEntry::getName() example

<?php

//this example is safe even in pages not encoded in UTF-8
//for those encoded in UTF-8, the call to mb_convert_encoding is unnecessary

$rar_file = rar_open('example.rar') or die("Failed to open Rar archive");

$entry = rar_entry_get($rar_file, 'Dir/file.txt') or die("Failed to find such entry");

echo "Entry name: " . mb_convert_encoding(
    htmlentities(
        $entry->getName(),
        ENT_COMPAT,
        "UTF-8"
    ),
    "HTML-ENTITIES",
    "UTF-8"
);

?>


PHP8 RarEntry::getMethod
PHP8 RarEntry::getPackedSize
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定